mIRC Homepage
Posted By: seanturner70 Scrambled word game - 02/11/08 12:19 AM
I would like a script that would choose a word and scramble it.

e.g.
Quote:
<User> !scramble
<Bot> What word is: lefl
<Bot> You have [20] seconds.
<User> !guess efll
<Bot> Wrong, Try again, you have [10] seconds left.
<User> !guess fell
<Bot> Great work User! You correctly guessed that the scrabled word was: Fell

Posted By: Kol Re: Scrambled word game - 02/11/08 10:22 AM
If you have a list of words in a txt, I'll do it.
Posted By: seanturner70 Re: Scrambled word game - 02/11/08 01:10 PM
ok....

I have like... A HUGE LIST!

I don't think it would be a good list to post ON the forums, so I pasted it into PasteBin
http://pastebin.com/f1ce1c1e7

Thanks Kol!

Posted By: Kol Re: Scrambled word game - 03/11/08 11:39 AM
Ok, got it. Done a bit of debugging, seems to have worked fine.

Code:
alias -l scramble {
  var %a,%b $1
  while ($numtok(%a,32) < $len($1)) var %a $addtok(%a,$r(1,$len($1)),32)
  return $regsubex(%a,/(\S+(?: |$))/g,$mid(%b,\1,1))
}
alias -l s_new {
  var -g %s_word $read(words.txt),%s_scramble $scramble(%s_word)
  msg $1 The scrambled word is: %s_scramble $+ . Type !guess to guess
  msg $1 You have [20] seconds.
  .timerscramble 1 20 s_fail $1
}
alias -l s_fail {
  msg $1 No one got it! The word was: %s_word
  msg $1 Time for new word...
  unset %s_word
  .timerscramble 1 3 s_new $1
}
alias -l s_cleanup {
  .timerscramble off
  unset %s_word %s_scramble
}
on *:TEXT:!scramble &:#: {
  if ($2 == start) {
    if (%s_scramble) notice $nick The game is already going... Type !word to see what the scrambled word it is
    else s_new #
  }
  elseif ($2 == stop) {
    if (%s_scramble) {
      msg # Game stopped by $nick $+ .
      s_cleanup
    }
  }
}
on *:TEXT:!guess &:#: {
  if (%s_word) {
    if ($2 == %s_word) {
      msg # Great work $nick $+ ! You correctly guessed the scrambled word was: %s_word
      msg # Time for new word...
      unset %s_word
      .timerscramble 1 3 s_new #
    }
    elseif ($2 != %s_word) msg # Wrong $nick $+ , try again. You have [[ $+ $timer(scramble).secs $+ ]] seconds left.
  }
}
on *:TEXT:!word:#: if (%s_word) notice $nick The scrambled word is: %s_scramble $+ , you have [[ $+ $timer(scramble).secs $+ ]] seconds left.


Commands are:

!scramble start - start the game
!scramble stop - stop the game
!guess WORD - guess a word
!word - tells you the current scramble word

Make sure you have the wordlist you supplied me saved in words.txt in your $mircdir.
Posted By: CeraVea Re: Scrambled word game - 24/03/22 03:08 AM
Tried to play this and still works. Hope this won't get me in trouble for stumbling an old thread but this one still works though.

Question:
Wonder if there's a way to somehow put some scoring script code like top players for the week then resets after?
Is it possible to keep it running in the channel when started but if no one's playing anymore after 3 questions it'll stop on its own? I'd love to get some code for it too if that's ok.. smile
© mIRC Discussion Forums