Kirby commented on a Page, Secret Word v2  -  Mar 12, 2009

Hmm, interesting game.

There are some things that you can change in this script.

on * :TEXT:*:?:{
  if ($1 = set) {
    if ($2 = s-word) set %s-word $3

can also be:

 on *:text:set s-word *:#: { set %s-word $3 }

Since there are no restrictions to whom can change the secret word, it's going to be a hard to keep track since it might constantly change.

When someone gets the secret word right, the bot hands him/her a random drink or snack from the .txt file; because the .txt file is so small, you can use variables and tokens to get a random item.
So you can just take out the on load and then change the third text event to:

on * :text:*:#:{
  if %s-word isin $1- {
    var %prizes Cheerwine|Twix|Pepsi|Dr. Pepper|7 Up|Hershey's Chocolate Bar
    msg $chan Hey, $+($nick,$chr(44)) you just said the secret word $+($chr(40),%s-word,$chr(41)), you get a prize!
    .describe $chan hands $nick a(n) $gettok(%prizes,$r(1,$numtok(%prizes,124)),124)
    unset %s-word
  }
}

If you haven't used tokens before, it's pretty easy.
$gettok "gets the token" from %prizes (first parameter), from the Nth token (second parameter), which is separated by $chr(124) (the |, which is the third parameter in $gettok). $r(1,$numtok(%prizes,124)) means a random selection between 1 and the number of tokens separated by $chr(124), in %prizes. Since you already know the # of tokens, which is 6, you can just use $r(1,6) instead.

  • I just realized that there was a command that you made, called !prize add. So instead of writing it into a .txt file, you can also /set it into %prizes. But I figure in this case, if you were to add MANY items to the prize bank, then .txt files would work better. If it's a subtle amount like 10, variables are okay.

If you're interested in learning tokens (which can really cut a lot of your script space), you should look it up in the help file for more info. /help Token Identifiers.

If you didn't already know, you can group things with $+ instead of the method you used.

%s-word $+ .

can be rewritten as

$+(%s-word,.)

. Same with

( $+ %s-word $+ )

, which can be rewritten as

$+($chr(40),%s-word,$chr(41))

. Because parentheses are parameters for scripts, you have to use $chr(40) "(" and $chr(41) ")" instead.

If this is going on a bot, then you might want to "silence" the /describe, by putting . (a period) in front of the command.
This same concept works with /msg and /timer

Some suggestions from me:

  • A trigger for starting the game.
  • Time-outs if nobody can get the word.
    I think it should be more game-based rather than just random guessing. :\ But it's just an idea.
 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.