Spin The Bottle

By Andyhighton on Mar 10, 2009

I know there are a lot of these around, haven't seen any that let the users add their own messages though, so i thought i would share mine.

I added a few to start you off, just add your own to the text file, or let your users add their own.

Commands:

!spinchan #Chan - Set the channel to use.

!ignorebot BotName - Ignore any bots in the channel. Can also be used to ignore a nick. Op+ only.

!must [add any message here] - Adds the users line to the list. [Example: !must GET NAKED NOW!]

!del [line to delete here] - Deletes the line from the list. [Example: !del GET NAKED NOW!]

!spin or !spinbottle - To spin the bottle.

Output:
Image

Tested this, and found no bugs, let me know if you find any..

Thanks to Shawn for his help again <3

On *:load: {
  write spin.txt run around naked. | write spin.txt poke <nick> | write spin.txt slap <nick> | write spin.txt leave this channel. | write spin.txt high 5 the ops.
}
on *:text:!spinchan*:#: {  
  set %spinchan $2
  notice $nick Spin The Bottle channel changed to: %spinchan 
} 
on $*:text:/^!spin(bottle)?/Si:%SpinChan:{ 
  :one
  var %victim $nick($chan,$rand(1,$nick($chan,0))) 
  if ($istok(%Bots,%Victim,58)) { goto one }
  else { 
    var %MustDo $replace($read(spin.txt),<nick>,$nick($chan,$rand(1,$nick($chan,0))))
    msg $chan 7 $+ $nick 5spins the bottle.... 
    .timer 1 5 msg $chan 5It lands on %victim $+ ! 
    .timer 1 7 msg $chan 7 $+ %victim 5must %MustDo
  } 
}
ON *:TEXT:!must*:#: {
  if ($2 == must) { notice $nick Syntax error. Example: !must read this notice }
  else { write spin.txt $2- | notice $nick "must $2- $+ " has been added.
  }
}
ON *:TEXT:!del*:#: {
  if ($2 == must) { notice $nick Syntax error. Do not include the "must" in the command. Example: !del leave this channel. | halt }
  else {
    set %delline $read(spin.txt, s, $2-)
    if ($readn == 0) { notice $nick No match was found. Please check the spelling and try again. Make sure you use the full line. | halt }
    else {
      set %Delline2 $read(spin.txt, l, $readn)
      write -dl $+ $readn spin.txt  
      notice $nick " $+ %delline2 $+ " Deleted
      unset %delline , %delline2
    }
  }
}
on *:text:!ignorebot*:#: {
  if ($nick isop $chan) {
    set %Bots $addtok(%bots,$2,58)
    notice $nick $2 will be ignored.
  }
}

Comments

Sign in to comment.
Andyhighton   -  Mar 11, 2009

Looks like slacker answered most posts lol, thanks :D

Forgot about the timers, so i have silenced them now.

 Respond  
Eugenio   -  Mar 11, 2009

Kirbys old days in IRC ?!?
rofl must of been in nappies......"diapers"

 Respond  
Kirby   -  Mar 11, 2009

Oh, I didn't see that. Dx

 Respond  
slacker   -  Mar 11, 2009

yeah but you have to think why they whent with a txt file. It's cuz they let users add their own lines, and you know it will fill up fast.

 Respond  
Kirby   -  Mar 11, 2009

This reminds me of my old days in IRC...spin the bottle was fun. xD

As for the script, you can improve upon some things.
This is one of the text events:

on $*:text:/^!spin(bottle)?/Si:%SpinChan:{ 
  :one
  var %victim $nick($chan,$rand(1,$nick($chan,0))) 
  if ($istok(%Bots,%Victim,58)) { goto one }
  else { 
    var %MustDo $replace($read(spin.txt),<nick>,$nick($chan,$rand(1,$nick($chan,0))))
    msg $chan 7 $+ $nick 5spins the bottle.... 
    timer 1 5 msg $chan 5It lands on %victim $+ ! 
    timer 1 7 msg $chan 7 $+ %victim 5must %MustDo
  } 
}

This on text event could be cleared up a bit.
In my opinion, while loops are more superior than goto loops, but it's just a preference. Although that works and does virtually the same thing, a while loop can accomplish things much faster:

while ($istok(%Bots,%victim,58)) { var %victim $nick($chan,$rand(1,$nick($chan,0))) }

. However, since this is all one text event, you don't need the

else {

, neither the

var %victim $nick($chan,$rand(1,$nick($chan,0))) }

. As for

    var %MustDo $replace($read(spin.txt),<nick>,$nick($chan,$rand(1,$nick($chan,0))))
    msg $chan 7 $+ $nick 5spins the bottle.... 
    timer 1 5 msg $chan 5It lands on %victim $+ ! 
    timer 1 7 msg $chan 7 $+ %victim 5must %MustDo

, the /var's are unecessary.
Instead of using a .txt file to browse your "dares", why don't you just /var or /set (depending on how you use those "dares" throughout the script), once at the beginning of the text file.
So the on load could be erased and replaced within the on text, and then randomly read through tokens. [ %mustdo run around naked|poke|slap|leave this channel|high 5 the ops ] and [ .timer 1 7 msg # $+(07,%victim) 5must $gettok(%mustdo,$r(1,$numtok(%mustdo,124)),124) ]

If I haven't mentioned, you can silence timers by adding . in front of them, as well as save some space by using $+ in a collective manner [ $+(a,b,c,d,e) would be the same as a $+ b $+ c $+ d $+ e ].

For such a small script and small amounts to work with, using .txt files is not worth it; variables and tokens work much better in this case, and increases the speed of the script by a small bit.

As for the rest, I'm sure you can improve those too.
Generally, coding can be improved, but I like the game idea; nice to see those around.

And Aucun: Grouping bunches of on text events into one big piece of chunk doesn't change significantly as opposed to multiples.

 Respond  
slacker   -  Mar 10, 2009

well on this it's fine to have them as is they only have 5 on text events in the code, and unless ur PC is crap it's not going to lag it.

 Respond  
Aucun50   -  Mar 10, 2009

LOL sorry i thought it said ini maybe i'm going blind idk, but the multiple on text can be fixed because it can get slow at time if you got like 20 of them.

 Respond  
slacker   -  Mar 10, 2009

@ Aucun50 they used a txt file not a ini and on these kinds of codes you tend to put alot of lines into the txt so a var would not be a good pick. as well about on useing alot of on text events it's the coders style to use alot or just 1.

 Respond  
Aucun50   -  Mar 10, 2009

I don't get why people are using ini files when a SIMPLE! var can do, why make it hard on the persons hard drive? When you can have 1 var do it without slowly take effect on the hard drive. I suggest you cut the ini file and use a var and/or $rand.

Also whats up with all these on texts now? i know it's easier but you only need one, better to use only one because later on when if you make a bigger script it will lag a lot with tons of on texts.

Overall not a bad script neat idea.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.