Word scramble game

By Olliegod on 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
}

Comments

Sign in to comment.
bourneident   -  Sep 30, 2010

/me searches Plornt files weeding through 1000's of xxx till he find the code for him ;) lol

oh well if you happen upon it some time let me know
thanks :)

 Respond  
[Plornt]   -  Sep 29, 2010

I made one of these ages ago (Totally different code) but yeah i would put the code on here but I really cant be assed to find it :/

 Respond  
bourneident   -  Sep 29, 2010

I don't know if you are still around but if you see this could you possibly add a !top10 option where scores are kept in a ini or hsh table i/e !top10 <1st place with a record of # points> !top10 which shows top 10 players with a !reset scores option that only the ops can do
plus if it's not to much trouble maybe make it !top10 daily weekly monthly kinda thing

 Respond  
[Plornt]   -  Jan 06, 2010

Vicos, this may be a late comment but that is regex, that means you can use:
!scram
@scram or
.scram
to start the game, you dont litrally type "[!@.]scram"

 Respond  
vicos2   -  Nov 24, 2009

yeah i don't understand, iput the
[!@.]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
......
into document and setings and save it named ScrambleWords.txt
than the script i put that in to remote
is that right way?

 Respond  
slacker   -  Mar 31, 2009

you have to add words first by typing !addwords word_here useing a diff mirc cuz this is a bot code. then type !scram to start it.

you can not run this in the same mirc you load it into. hence bot code.

 Respond  
Sub-Xero   -  Mar 31, 2009

How do you trigger the game? Everything I try doesn't work.

 Respond  
fina82   -  Mar 30, 2009

do what???

 Respond  
Sub-Xero   -  Mar 20, 2009

I may be slow but I can't seem to figure out how to work this thing. How do you do it?

 Respond  
fina82   -  Mar 20, 2009

i wanna put top10, can u teach me??

 Respond  
ChaosDragoon   -  Mar 07, 2009

I am using this for my bot but it isn't deleting the words from its index when I ask it to delete it...also, how can I change it so that it gives me a random amount of points instead of 5 everytime? Also, I'm new so I probably won't get exactly what you write down...probably better to just send me the altered code.

 Respond  
bmann_420   -  Feb 04, 2009

Sorry, im new to mirc also, but is it just me or does this code only work in 1 channel? I have this bot in 2 channels, but it only wants to work in one. Read through the code, and diddnt see anything pertaining to a channel preference :/

 Respond  
Deimius   -  Jun 07, 2008

Awesome work Olliegod. I\'ve added this to my bot.

One minor suggestion, if words get added with any Capital letters in them, in a game, the scrambled word also has that same letter capitalized too. May I suggest adding a simple $lower() to a few of the messages.

Great Job.

 Respond  
Olliegod   -  Oct 19, 2007

I believe the command:
/remove scramblewords.txt
would solve that problem. If you want to elaborate on that further, go ahead, but I see no purpose for it really.

 Respond  
Mono   -  Oct 18, 2007

make it where we can delete all the words in it

 Respond  
suzybeth   -  Aug 08, 2007

Ok, I am such a noob at these things. Where exactly do I put this snippet at? I have created a ScrambleWords.txt file. I probably put it int he wrong place but I made a new file under remotes. Since it isn\'t working then i can only suppose I put it in the wrong place. Thansk for any help

 Respond  
Olliegod   -  Jun 24, 2007

It will write it itself when someone guesses correctly.

 Respond  
ermansanidhya   -  Jun 23, 2007

oh yeah, this only script.where the scrambel.ini?! :)

 Respond  
Olliegod   -  Jun 22, 2007

Well my code is working perfectly fine for its purpose. As a wise man once said, \"If aint broke, don\'t fix it.\" Besides, I would rather not have to put credits in to say it wasn\'t my code if I don\'t need to.

 Respond  
Callison1   -  Jun 22, 2007

I like it

 Respond  
xDaeMoN   -  Jun 22, 2007

The spaces can be removed if you like ;) The code was just a suggestion =)

 Respond  
Olliegod   -  Jun 22, 2007

And also, that code leaves spaces between the letters.

 Respond  
xDaeMoN   -  Jun 21, 2007

Here\'s a shorter version of scramble, made by Sigh_ :)

alias scramble {
  var %c
  while ($calc(1+$numtok(%c,32)) <= $len($1)) %c = $instok(%c,$mid($1,$v1,1),$r(0,$v1),32)
  return %c
}
 Respond  
|MELIORITE|   -  Jun 21, 2007

Looks neat to me. I haven\'t tested it yet, but nice job :)

 Respond  
Olliegod   -  Jun 21, 2007

Updated again to allow multiple words to be added at once.

 Respond  
Callison1   -  Jun 21, 2007

Cool

 Respond  
Olliegod   -  Jun 21, 2007

Thanks for the suggestion Callison1, I added that in and I just restricted it to ops.

 Respond  
Callison1   -  Jun 21, 2007

on $*:TEXT:/^[!@.]remword/Si:#: {
var %d = $read(ScrambleWords.txt, w, $2)
if (( %d == $null )) { notice $nick That word is not in the list | halt }
write -ds $+ $2 ScrambleWords.txt $$2
msg # The word $2 has been removed.
}

It would look something like that :P
You might not want to use anything like that if you think it could cause trouble with people continually removing words but it helps to remove words that are not real words, but it\'s just a suggestion, you might want to incorporate a system where only people who\'s address is in another text file, a kind of \'moderator\' list, but again, just a suggestion.

 Respond  
Callison1   -  Jun 21, 2007

I am testing it now and it seems quite good. One thing I used in my hangman script that might be worth considering is a [!@]remword command for easy removal of words.

 Respond  
Olliegod   -  Jun 21, 2007

Added in a points thing.

 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.