Secret Word v2

By MaxEvans on Mar 12, 2009

I got this idea from a guessing game. I thought it would be cool to have a "secret" word type game. This is set up so you can message your bot and set the secret word. And if anyone says the secret word in any form, sentence, paragraph, it'll alert the user who said the word. It also unsets the secret word variable so each word can't be said twice.

How to use:

  1. Save the code as S-word.mrc.

  2. In your bot, type /load -rs S-word.mrc. It'll ask you if you want to run initialization commands, click yes. The script will automatically write a "prizes.txt" file with several prizes in it. You can add more later. After it's loaded, click the commands menu, and open the dialog to set the owner and add prizes.

  3. Message your bot with "set s-word (word you want)" without quotes, or type /msg yourbot'sname set s-word (word you want). The bot will confirm the secret word is set to the word you want. Now all you have to do is wait for someone to say the word.

  4. To add prizes just type !Prize add (your prize). It can be more than one word, like "Root Beer" or anything of the like. The bot will confirm the prize added to the prize bank.

(((((UPDATES: As of January 2012, I have added some new stuff to this script. I've added in coding that will query the person who said the secret word and says something like "Send Maxwell a PM with another word to set as the secret word. Since you said the secret word, you get to choose the next one. But don't try saying the secret word once it's set, or you'll get a five minute ban. Let someone else get it. =)." This was my brother's idea, so I have to credit him for it.

Also I have set it so the person cannot say the secret word again once they suggest a new one. It administers a five minute ban for trying to win another prize. This was my idea to keep the "game" fair. It will reset the secret word so you can set it again.

I also have added a dialog that allows you to set the owner, secret word, and edit prizes directly from the dialog. I also left it so you can set the secret word remotely by sending a query to the bot as it was in the first version, as well as adding prizes remotely too. That way other ops can add prizes without having to be at the computer running the script.)))))

Examples:

Setting the secret word in query: Maxwell: set s-word taco [Game|Bot]: Secret word is now set as taco.

Winning: ~Maxwell : Man, I want a soft taco. [Game|Bot]: Hey, Maxwell, you just said the secret word (taco), you get a prize! ! @[Game|Bot] hands Maxwell a Cheerwine

"Winning" again: ~Maxwell: This is crazy.  :: modes set(#GeekUnderground): +b Maxwell by [Game|Bot] [Game|Bot]: Hey, Maxwell, you get a five minute ban for trying to win another prize. Cheaters never win. The secret word has been reset as well.

Dialog: Image

If anyone has any suggestions for this, let me know. I'm always up for adding stuff to any of my scripts.

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
;         Secret Word v2        ;
;         By: Max Evans         ;
;       irc.geekshed.net        ;
;   #GeekUnderground & #Chris   ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;

dialog s-word {
  title "Secret Word Setup"
  size -1 -1 168 124
  option dbu
  box "Prize Bank", 1, 5 4 86 98
  box "Bot Owner", 2, 95 4 69 50
  box "Secret Word", 3, 95 58 69 44
  edit %sw-owner, 4, 104 20 50 10, center
  button "Set", 5, 103 37 23 9
  button "Reset", 6, 131 37 23 9
  button "Reset", 7, 132 86 23 9
  button "Set", 8, 104 86 23 9
  edit %s-word, 9, 105 69 50 10, center
  list 10, 8 12 80 65, size
  button "Close", 11, 76 110 23 9, ok
  button "Add", 13, 22 85 23 9
  button "Delete", 15, 50 85 23 9
}

on 1:dialog:s-word:init:0:{
  $iif($isfile(prizes.txt),loadbuf -o s-word 10 prizes.txt)
  did $iif(%sw-owner,-m,-n) $dname 4
  did $iif(%s-word,-m,-n) $dname 9
}

on *:dialog:s-word:sclick:*: {
  if ($did == 13) { write prizes.txt $?="Add New Prize To Prize Bank") | did -r s-word 10 | loadbuf -o s-word 10 prizes.txt }
  if ($did == 15) {  write -dl $+ $did(10).sel prizes.txt | did -r s-word 10 | loadbuf -o s-word 10 prizes.txt }
  if ($did == 5) { %sw-owner = $did(4) | did -m s-word 4 }
  if ($did == 6) { unset %sw-owner | did -n s-word 4 | did -r s-word 4 }
  if ($did == 8) { %s-word = $did(9) | did -m s-word 9 }
  if ($did == 7) { unset %s-word | did -n s-word 9 | did -r s-word 9 }
}

on *:load: { var %p = Cheerwine|Twix|Pepsi|Dr. Pepper|7 Up|Hershey's Chocolate Bar | tokenize 124 %p | write prizes.txt $* }

on *:TEXT:!prize add *:#: {
  if ($nick isop $chan) {
    write prizes.txt $3-
    .notice $nick Prize ( $+ $3- $+ ) has been added to the prize bank.
  }
  else {
    .notice $nick Sorry, you must be an op in $chan to add prizes.
  }

}

on *:TEXT:set s-word *:?: {
  if ($nick == %sw-owner) {
    set %s-word $3 
    .msg $nick Secret word is now set as %s-word $+ .
  }
  else { 
    .msg $nick Sorry, only %sw-owner can set the secret word. 
  }
}

on *:TEXT:*:#:{
  if %s-word isin $1- {
    if ($nick == %lastnick) {
      ban -u300 $chan %lastnick
      .msg $chan Hey, %lastnick $+ , you get a five minute ban for trying to win another prize. Cheaters never win. The secret word has been reset as well.
      unset %lastnick
      unset %s-word
    }
    else {
      unset %lastnick
      set %lastnick $nick    
      .msg $chan Hey, $nick $+ , you just said the secret word ( $+ %s-word $+ ), you get a prize!
      .describe $chan hands $nick a(n) $read(prizes.txt)
      unset %s-word
      .msg %lastnick Send %sw-owner a PM with another word to set as the secret word. Since you said the secret word, you get to choose the next one. But don't try saying the secret word once it's set, or you'll get a five minute ban. Let someone else get it. =)
    }
  }
}
menu * {
  .Secret Word set up: { secret }
}

alias secret { dialog -m s-word s-word }

Comments

Sign in to comment.
MaxEvans   -  Jan 19, 2012

And, in case anyone wants the older version here it is:

on *:load: { var %p = Cheerwine|Twix|Pepsi|Dr. Pepper|7 Up|Hershey's Chocolate Bar | tokenize 124 %p | write prizes.txt $* }

on *:TEXT:!prize add *:#: {
  if ($nick isop $chan) {
    write prizes.txt $3-
    .notice $nick Prize ( $+ $3- $+ ) has been added to the prize bank.
  }
  else {
    .notice $nick Sorry, you must be an op in $chan to add prizes.
  }

}

on *:TEXT:set s-word *:?: {
  if ($nick == %sw-owner) {
    set %s-word $3 
    .msg $nick Secret word is now set as %s-word $+ .
  }
  else { 
    .msg $nick Sorry, only %sw-owner can set the secret word. 
  }
}

on *:TEXT:*:#:{
  if %s-word isin $1- {
    .msg $chan Hey, $nick $+ , you just said the secret word ( $+ %s-word $+ ), you get a prize!
    .describe $chan hands $nick a(n) $read(prizes.txt)
    unset %s-word
  }
}

menu * {
  .Secret Word set up
  ..Set Bot Owner: { set %sw-owner $?="What Nick Would You Like As The Bot Owner?" | echo -a Secret Word Bot Owner Is Now Set As %sw-owner }
}
More
 Respond  
Aucun50   -  Mar 12, 2009

Seems kirby got it all :(

Nice Game.

More
 Respond  
MaxEvans   -  Mar 12, 2009

Sweet, I like that better than having write | write , etc. And I didn't even notice the missing bracket, but I put it in there. So, it's all fixed.

More
 Respond  
Kirby   -  Mar 12, 2009

Ah, now I get what you were doing...

Looks much better, but missing a bracket at the end. Also: What I said about putting a period in front of a command to "silence" it, if you look at a channel the bot said something, you won't be able to see it (through the bot's perspective); but other users can see it, so it's okay.

For the on load, instead of putting /write prizes.txt, you can /var them and then write each of them to it without the repetitivity.

on *:load: { var %p = Cheerwine|Twix|Pepsi|Dr. Pepper|7 Up|Hershey's Chocolate Bar | tokenize 124 %p | write jokes.txt $* }
More
 Respond  
MaxEvans   -  Mar 12, 2009

I just wrote in an owner variable, so only the owner can set the word. And thing is, it's not exactly just a random guessing game. That's what the guessing games on here are for. This is more of an element of surprise, you don't know you'll say the "secret word" type thing. That's why it's called "secret word". Nobody knows there's a word guessing, no spamming to get the word. The bot will just randomly alert a user if they say the "secret word". =] It's more fun that way. Or, I think so.

And for the txt file. I made it that way so people could add their own prizes to it. I just had it write a starter txt file. So it'll work on load. Ops can add random things to the prize bank. Thus populating the txt file more.

Thanks for some of the ideas, I used the first one, shorter code.

More
 Respond  
Kirby   -  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.
More
 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.