The other day I threw together a 'cut the wire' game for some guys in my channel. I've seen plenty of them over the years, but I'm teaching some of these guys how to code in MSL, so I figured I'd write my own and walk them through it.
For this reason, the script is like twice as long as it needs to be, but I figured it would be a good way for them to learn different functions and options.
You choose someone to 'bomb.' They will be given 45 seconds and 1 guess to correctly cut the correct wire, with 5 choices. This does keep track of wins, losses, and lose-by-default/timeout.
If you cut the wrong wire, or don't respond fast enough, you will get kicked from the channel if the bot is hosted, obviously. It works regardless of whether or not the bot is hosted, you will just get a "you're not channel operator" message.
The option to kick can be easily removed from this script without messing anything else up, obviously just remove all instances of lines with 'kick # %bombee'
Anyway, I apologize again for oversimplifying and making it so long, but it works, so enjoy!
on *:TEXT:!Bomb *:#: {
if $2 != $me {
if %cutwire != 1 {
if $2 = Random {
set %bombwire $rand(1,5)
:one
set %bombee $nick(#,$r(1,$nick(#,0,a)),a)
if %bombee = $me { goto one }
set %cutwire 1
if %bombwire = 1 { set %bombwirecolor red | set %wireright 4RED }
if %bombwire = 2 { set %bombwirecolor orange | set %wireright 7ORANGE }
if %bombwire = 3 { set %bombwirecolor yellow | set %wireright 8YELLOW }
if %bombwire = 4 { set %bombwirecolor green | set %wireright 3GREEN }
if %bombwire = 5 { set %bombwirecolor blue | set %wireright 2BLUE }
if %bombstats. [ $+ [ %bombee ] ] != 1 { set %bombstats. [ $+ [ %bombee ] ] 1 | set %bombwin. [ $+ [ %bombee ] ] 0 | set %bomblose. [ $+ [ %bombee ] ] 0 | set %bombtimeout. [ $+ [ %bombee ] ] 0 }
notice %bombee Someone just activated a bomb with a 45 second timer under your chair in $chan $+ ! Cut which wire? 4RED 7ORANGE 8YELLOW 3GREEN 2BLUE
msg $chan $nick just activated a bomb with a 45 second timer under %bombee $+ 's chair! %bombee needs to pick a wire to cut: 4RED 7ORANGE 8YELLOW 3GREEN 2BLUE
timerBomb 1 46 msg $chan 3TICKA-8TICKA-7TICKA-4TICKA-BOOM! %bombee took too long, and got asploded. Stupid %bombee $+ ! All they had to do was cut the %wireright wire...
msg $chan Tick-tock, %bombee $+ , Tick-tock...
timer 1 47 unset %bombwire
timer 1 47 unset %bombee
timer 1 47 unset %cutwire
timerStats 1 47 inc %bombtimeout. [ $+ [ %bombee ] ] 1
timerkick 1 47 kick # %bombee Shoulda cut the %wireright wire, %bombee
}
elseif $2 ison $chan {
set %bombwire $rand(1,5)
set %bombee $2
set %cutwire 1
if %bombwire = 1 { set %bombwirecolor red | set %wireright 4RED }
if %bombwire = 2 { set %bombwirecolor orange | set %wireright 7ORANGE }
if %bombwire = 3 { set %bombwirecolor yellow | set %wireright 8YELLOW }
if %bombwire = 4 { set %bombwirecolor green | set %wireright 3GREEN }
if %bombwire = 5 { set %bombwirecolor blue | set %wireright 2BLUE }
if %bombstats. [ $+ [ $2 ] ] != 1 { set %bombstats. [ $+ [ $2 ] ] 1 | set %bombwin. [ $+ [ $2 ] ] 0 | set %bomblose. [ $+ [ $2 ] ] 0 | set %bombtimeout. [ $+ [ $2 ] ] 0 }
notice $2 Someone just activated a bomb with a 45 second timer under your chair in $chan $+ ! Cut which wire? 4RED 7ORANGE 8YELLOW 3GREEN 2BLUE
msg $chan $nick just activated a bomb with a 45 second timer under $2 $+ 's chair! $2 needs to pick a wire to cut: 4RED 7ORANGE 8YELLOW 3GREEN 2BLUE
timerBomb 1 46 msg $chan 3TICKA-8TICKA-7TICKA-4TICKA-BOOM! $2 took too long, and got asploded. Stupid $2 $+ ! All they had to do was cut the %wireright wire...
msg $chan Tick-tock, $2 $+ , Tick-tock...
timer 1 47 unset %bombwire
timer 1 47 unset %bombee
timer 1 47 unset %cutwire
timerStats 1 47 inc %bombtimeout. [ $+ [ $2 ] ] 1
timerkick 1 47 kick # $2 Shoulda cut the %wireright wire, $2
}
else {
msg $chan Sorry, but I don't see a $2 in this channel...
}
}
else {
msg $chan Someone else is currently being bombed. Please wait until they asplode or redeem themself by cutting the correct wire!
}
}
else {
msg $chan I can't bomb myself, stupid!
}
}
on *:TEXT:red:#: {
if $nick = %bombee {
if $1 = %bombwirecolor {
msg $chan HOLY POOP-CRAP! $nick JUST SAVED THEMSELF BY CUTTING THE 4RED WIRE!
inc %bombwin. [ $+ [ $nick ] ] 1
timerBomb off
timerKick off
unset %bombwire
unset %bombee
unset %cutwire
unset %bombwirecolor
}
else {
msg $chan 3TICKA-8TICKA-7TICKA-4TICKA-BOOM! $nick cut the 4RED wire and suffered the consequences. Stupid stupid $nick $+ . Shoulda cut the %wireright wire!
inc %bomblose. [ $+ [ $nick ] ] 1
timerBomb off
timerKick off
kick # $nick Shoulda cut the %wireright wire, $nick
unset %bombwire
unset %bombee
unset %cutwire
unset %bombwirecolor
}
}
}
on *:TEXT:green:#: {
if $nick = %bombee {
if $1 = %bombwirecolor {
msg $chan HOLY POOP-CRAP! $nick JUST SAVED THEMSELF BY CUTTING THE 3GREEN WIRE!
inc %bombwin. [ $+ [ $nick ] ] 1
timerBomb off
timerKick off
unset %bombwire
unset %bombee
unset %cutwire
unset %bombwirecolor
}
else {
msg $chan 3TICKA-8TICKA-7TICKA-4TICKA-BOOM! $nick cut the 3GREEN wire and suffered the consequences. Stupid stupid $nick $+ . Shoulda cut the %wireright wire!
timerBomb off
timerKick off
inc %bomblose. [ $+ [ $nick ] ] 1
kick # $nick Shoulda cut the %wireright wire, $nick
unset %bombwire
unset %bombee
unset %cutwire
unset %bombwirecolor
}
}
}
on *:TEXT:yellow:#: {
if $nick = %bombee {
if $1 = %bombwirecolor {
msg $chan HOLY POOP-CRAP! $nick JUST SAVED THEMSELF BY CUTTING THE 8YELLOW WIRE!
inc %bombwin. [ $+ [ $nick ] ] 1
timerBomb off
timerKick off
unset %bombwire
unset %bombee
unset %cutwire
unset %bombwirecolor
}
else {
msg $chan 3TICKA-8TICKA-7TICKA-4TICKA-BOOM! $nick cut the 8YELLOW wire and suffered the consequences. Stupid stupid $nick $+ . Shoulda cut the %wireright wire!
timerBomb off
timerKick off
inc %bomblose. [ $+ [ $nick ] ] 1
kick # $nick Shoulda cut the %wireright wire, $nick
unset %bombwire
unset %bombee
unset %cutwire
unset %bombwirecolor
}
}
}
on *:TEXT:blue:#: {
if $nick = %bombee {
if $1 = %bombwirecolor {
msg $chan HOLY POOP-CRAP! $nick JUST SAVED THEMSELF BY CUTTING THE 2BLUE WIRE!
inc %bombwin. [ $+ [ $nick ] ] 1
timerBomb off
timerKick off
unset %bombwire
unset %bombee
unset %cutwire
unset %bombwirecolor
}
else {
msg $chan 3TICKA-8TICKA-7TICKA-4TICKA-BOOM! $nick cut the 2BLUE wire and suffered the consequences. Stupid stupid $nick $+ . Shoulda cut the %wireright wire!
timerBomb off
timerKick off
inc %bomblose. [ $+ [ $nick ] ] 1
kick # $nick Shoulda cut the %wireright wire, $nick
unset %bombwire
unset %bombee
unset %cutwire
unset %bombwirecolor
}
}
}
on *:TEXT:orange:#: {
if $nick = %bombee {
if $1 = %bombwirecolor {
msg $chan HOLY POOP-CRAP! $nick JUST SAVED THEMSELF BY CUTTING THE 7ORANGE WIRE!
inc %bombwin. [ $+ [ $nick ] ] 1
timerBomb off
timerKick off
unset %bombwire
unset %bombee
unset %cutwire
unset %bombwirecolor
}
else {
msg $chan 3TICKA-8TICKA-7TICKA-4TICKA-BOOM! $nick cut the 7ORANGE wire and suffered the consequences. Stupid stupid $nick $+ . Shoulda cut the %wireright wire!
timerBomb off
timerKick off
inc %bomblose. [ $+ [ $nick ] ] 1
kick # $nick Shoulda cut the %wireright wire, $nick
unset %bombwire
unset %bombee
unset %cutwire
unset %bombwirecolor
}
}
}
on *:TEXT:!Stats *:#: {
if %bombstats. [ $+ [ $2 ] ] != 1 {
msg $chan $2 has not yet been bombed. Let's bomb them!
}
else {
msg $chan $2 has cut the correct wire %bombwin. [ $+ [ $2 ] ] times. $2 has cut the wrong wire %bomblose. [ $+ [ $2 ] ] times. $2 has not cut a wire, losing by default, %bombtimeout. [ $+ [ $2 ] ] times.
}
}
on *:TEXT:!stats:#: {
if %bombstats. [ $+ [ $nick ] ] != 1 {
msg $chan $nick has not yet been bombed. Let's bomb them!
}
else {
msg $chan $nick has cut the correct wire %bombwin. [ $+ [ $nick ] ] times. $nick has cut the wrong wire %bomblose. [ $+ [ $nick ] ] times. $nick has not cut a wire, losing by default, %bombtimeout. [ $+ [ $nick ] ] times.
}
}
Thanks for the feedback!
I tend to do it the second way you mentioned, but for the ones who I am teaching, I want them to always make sure that they are doublechecking their sets and unsets, just like they would with brackets. :)
I also debated doing "on :TEXT::#:" and then specifying the colors within that, but decided to go with the colors separately, thought that might be a little easier to understand as well.
a lot of redundancy with-in the snippet, but i guess it's an ok teaching tool as you stated in ur description.
you could show them better ways to go about things tho
for 1 like how you have
unset %bombwire
unset %bombee
unset %cutwire
unset %bombwirecolor
you could do
unset %bombwire %bombee %cutwire %bombwirecolor
or name the var like %bomb.wire %bomb.ee %bomb.wire %bomb.wirecolor
then do
unset %bomb.*