Code: Select all
# From what file are the words that will be scrambed?
set scramblefile "scramble.txt"
# How many seconds to play a scrambled word?
set ssecs 60
# Show the answer if nobody got the answer?
# 0 for NO and 1 for YES.
set sanswer 0
### Done with configurations, do not edit past here unless you know TCL. ###
# binds #
bind pub o !scramble pub:scramble
# messages #
set scongrats {
"Well done"
"Nice going"
"Way to go"
"You got it"
"That's the way"
"Show 'em how it's done"
"Check out the big brain on"
}
set snonegotit {
"Nobody got it right."
"Hello? Anybody home?"
"You're going to have to try harder!"
"Are these too tough for you?"
"Am I alone here or what?"
}
# scramble #
proc pub:scramble {nick uhost hand chan text} {
if {![file exists $::scramblefile]} {
putserv "PRIVMSG $chan :\002Error\002: $::scramblefile dose not exist."
return
}
set sstarted 0
foreach bla [utimers] {
if {[string match "nobody:gotit*" [lindex $bla 1]]} {
set sstarted 1
}
}
if {$sstarted == 1} {
putserv "PRIVMSG $chan :HEY! One word at a time!"
return
}
set file [open "$::scramblefile" r]
set data [split [read $file] "\n"]
close $file
set word [lindex $data [rand [llength $data]]]
putserv "PRIVMSG $chan :[scramble $word]"
# stuff #
bind pub - $word pub:gotit
utimer $::ssecs [list nobody:gotit $word $chan]
}
# got it! #
proc pub:gotit {nick uhost hand chan text} {
putserv "PRIVMSG $chan :[lindex $::scongrats [rand [llength $::scongrats]]] $nick.."
# clean #
foreach bla [utimers] {
if {[string match "nobody:gotit*" [lindex $bla 1]]} {
killutimer [lindex $bla 2]
}
}
unbind pub - $::lastbind pub:gotit
}
# loosers! #
proc nobody:gotit {word chan} {
if {$::sanswer == 1} {
putserv "PRIVMSG $chan :The answer was \002$word\002.. [lindex $::snonegotit [rand [llength $::snonegotit]]]"
unbind pub - $word pub:gotit
return
}
putserv "PRIVMSG $chan :[lindex $::snonegotit [rand [llength $::snonegotit]]]"
unbind pub - $word pub:gotit
}
# scramble proc by stdragon @ forum.egghelp.org
proc scramble {word} {
set letters [split $word ""]
set newword ""
while {[llength $letters]} {
set i [rand [llength $letters]]
append newword [lindex $letters $i]
set letters [lreplace $letters $i $i]
}
return $newword
}