Word scramble game
Platform: mIRC
Published Jun 21, 2007
Updated Jun 21, 2007
This is a game I made which will scramble a word and you must guess the original word correctly.
Commands are:
[!@.]scram or [!@.]scramble to start the game
[!@.]guess (word here) to guess the word
[!@.]addword (words seperated by spaces) to add new words to the file
[!@.]remword (words seperated by spaces) deletes words from the file (must be an op to use this)
[!@.]endscram to end the current game
[!@.]scrampoints to view your current points or [!@.]scrampoints (name) to view that persons current points
[!@.]hint for a hint at the current word
Sorry I don't have a list of words to go with it.
on $*:TEXT:/^[!@.]scram(ble)?$/Si:#: {
if $($+(%,scram.scramword.,$chan),2) { .msg $chan Theres already a scramble game going! The current scrambled word is $qt(%scram.scramword. [ $+ [ $chan ] ]) }
else {
set $+(%,scram.origword.,$chan) $read(ScrambleWords.txt)
set $+(%,scram.scramword.,$chan) $scramble(%scram.origword. [ $+ [ $chan ] ])
.msg $chan Scrambled word is $qt(%scram.scramword. [ $+ [ $chan ] ]) $+ . To guess at what the word is type !guess (Your guess here)
}
}
on $*:TEXT:/^[!@.]guess/Si:#: {
if $($+(%,scram.scramword.,$chan),2) {
if ($2 != %scram.origword. [ $+ [ $chan ] ]) { .msg $chan Sorry that isn't right! Keep trying! }
else {
writeini Scramble.ini points $nick $iif($readini(Scramble.ini,points,$nick),$calc($readini(Scramble.ini,points,$nick) + 5),5)
.msg $chan That's correct! Great job $nick $+ ! You now have $readini(Scramble.ini,points,$nick) Points.
unset $+(%,scram.*.,$chan)
}
}
}
on $*:TEXT:/^[!@.]addwords?/Si:#: {
var %x = 1
while ($gettok($2-,%x,32)) {
if (!$read(ScrambleWords.txt,w,$gettok($2-,%x,32))) {
write ScrambleWords.txt $gettok($2-,%x,32)
var %added = %added $gettok($2-,%x,32)
}
inc %x
}
.msg $chan $iif(!%added,No new words added.,Words added: $replace(%added,$chr(32),$chr(44)))
}
on $*:TEXT:/^[!@.](rem(ove)?|del(ete)?)words?/Si:#: {
if ($nick isop $chan) {
var %x = 1
while ($gettok($2-,%x,32)) {
if ($read(ScrambleWords.txt,w,$gettok($2-,%x,32))) {
var %deleted = %deleted $gettok($2-,%x,32)
write $+(-dl,$readn) ScrambleWords.txt
}
inc %x
}
.msg $chan $iif(!%deleted,None of those words were in the file.,Words deleted: $replace(%deleted,$chr(32),$chr(44)))
}
else { .notice $nick Access denied. }
}
on $*:TEXT:/^[!@.](end|stop)scram(ble)?$/Si:#: {
if $($+(%,scram.scramword.,$chan),2) {
.msg $chan Ended the current game. Word was $qt(%scram.origword. [ $+ [ $chan ] ]) $+ . Better luck next time.
unset $+(%,scram.*.,$chan)
}
}
on $*:TEXT:/^[!@.]scrampoints?/Si:#: {
if (!$2) {
.msg $chan You have $iif($readini(Scramble.ini,points,$nick),$readini(Scramble.ini,points,$nick),0) points $nick $+ .
}
else {
.msg $chan $2 has $iif($readini(Scramble.ini,points,$2),$readini(Scramble.ini,points,$2),0) points.
}
}
on $*:TEXT:/^[!@.]hint$/Si:#: {
if $($+(%,scram.scramword.,$chan),2) {
.msg $chan The first two letters of the current word are $qt($left(%scram.origword. [ $+ [ $chan ] ],2))
}
}
alias scramble {
while ($len(%scrambled) < $len($1)) {
var %current = $r(1,$len($1))
if ($istok(%used,%current,32) == $false) {
var %scrambled = %scrambled $+ $mid($1,%current,1)
var %used = %used %current
}
}
return %scrambled
}