mIRC Homepage
Posted By: Pariah Acronym Game - 26/03/05 07:59 AM
can anyone tell me where i could find a game like this to add to my bot?
Posted By: SladeKraven Re: Acronym Game - 26/03/05 08:27 AM
What is an acronym game?
Posted By: Pariah Re: Acronym Game - 26/03/05 08:33 AM
It is like a trivia game, the bot will tell you the letters of the acronym, and then everyone starts guessing as to what it stands for.
Posted By: RusselB Re: Acronym Game - 26/03/05 09:00 AM
Code:
 on *:text:*:#:{
if $1 == !acronym {
if !%ac { set %ac 1 }
else { describe # Current Acronym %acronym hasn't been guessed }
set %acronym $read(acronym.txt)
set %response $right(%acronym,$calc(-1 * ($pos(%acronym,$chr(32),1))))
set %acronym $remove(%acronym,%response)
set %response $right(%response,-1)
describe # Acronym is %acronym
}
elseif $1 == %response {
describe # Congratulations $nick
unset %ac
describe # Type !acronym to start another game
}
else { describe # Sorry $nick, but that's not the correct response }
}
 


Just make sure that you have the information in the text file (acronym.txt) in the correct order. The acronym, then a space character, then the correct response.

This was quickly done, so I can't guarantee anything, but I think it should work
Posted By: DaveC Re: Acronym Game - 26/03/05 09:52 AM
The setting up the acronym was a bit dodgy but beyond that looked good.
* I also havent checked this code, its late sorry

Code:
on *:text:*:#:{
  tokenize 32 $strip($1-)
  if ($1 == !acronym) {
    if !%ac {
      set %ac 1
      set %acronym $read(acronym.txt)
      set %response $gettok(%acronym,2-,32)
      set %acronym $gettok(%acronym,1,32)
      describe # Acronym is %acronym
    }
    else {
      describe # Current Acronym %acronym hasn't been guessed.
    }
  }
  elseif ($1- == %response) {
    describe # Congratulations $nick You have the answer!
    unset %ac
    describe # Type !acronym to start another game.
  }
  else {
    describe # Sorry $nick, but that's not the correct response
  }
}


acronym.txt format as follows
omg oh my god
cpu central processing unit
ape a purple elephant <snicker snicker>
Posted By: Pariah Re: Acronym Game - 26/03/05 10:07 AM
thank you very much russel and dave grin would it be possible to put a timer on how long they have to respond before it times out?
Posted By: DaveC Re: Acronym Game - 26/03/05 10:28 AM
Code:
on *:text:*:#:{
  tokenize 32 $strip($1-)
  if ($1 == !acronym) {
    if !%ac {
       new.acronym #
    }
    else {
      describe # Current Acronym %acronym hasn't been guessed.
    }
  }
  elseif ($1- == %response) {
    describe # Congratulations $nick You have the answer!
    unset %ac
    describe # Type !acronym to start another game.
    .timer.acronym.end.turn off
  }
  else {
    describe # Sorry $nick, but that's not the correct response
  }
}
alias -l new.acronym {
  set %ac 1
  set %acronym $read(acronym.txt)
  set %response $gettok(%acronym,2-,32)
  set %acronym $gettok(%acronym,1,32)
  describe $1 Acronym is %acronym
  .timer.acronym.end.turn 1 300 acronym.end.turn $1
  ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 300 is 300 seconds set that to what ya want.
}
;
;------------------------------------------------------------ 
alias -l acronym.end.turn {
  describe $1 Times up you loosers it was %response
  unset %ac
  describe $1 Type !acronym to start another game.
}  
;------------------------------------------------------------ 
;
; * choose which of these two you want the top one end the turn the bottom one does to but starts another turn on its own. (delete the one you dont want
;
;------------------------------------------------------------ 
alias -l acronym.end.turn {
  describe $1 Times up you loosers it was %response
  describe $1 So you all get to play again try harder this time!
  new.acronym $1
}
;------------------------------------------------------------
;
Posted By: RusselB Re: Acronym Game - 26/03/05 11:06 AM
Like you said, Dave...it was late when I did that
Posted By: Pariah Re: Acronym Game - 26/03/05 11:42 AM
thanks tremendously dave, only problem i seem to have is with
Code:
else {
    describe # Sorry $nick, but that's not the correct response
   }

would there be an easy way to put an off trigger in it?
Posted By: RusselB Re: Acronym Game - 26/03/05 03:55 PM
Oops...change that to read
Code:
else { describe # Sorry $nick $+ , but that's not the correct response } 


As to turning the game on/off, put the following at the top of the code
Code:
on *:text:!acgame &amp;:#:{
$iif($2 == on,.enable #acronym,.disable #acronym)
}
#acronym off


and make the last line of the code
Code:
#acronym end


The command to turn the game on is !acgame on
anything else will turn the game off

If you need/want an updated code, with these changes, say so and I'll put them up. Unfortunately copy & pasting from code from this forun doesn't put in line returns where they occur in the actual code.
Posted By: DaveC Re: Acronym Game - 26/03/05 10:56 PM
Quote:
Code:
on *:text:!acgame &amp;:#:{
$iif($2 == on,.enable #acronym,.disable #acronym)
}
#acronym off


heheh I like that nice style of enabling and disabling on the fly
Posted By: Pariah Re: Acronym Game - 27/03/05 06:06 AM
I tried to make myself another little game modeled after the code you posted, but it doesnt work for me like the other one did, think you could maybe tell me where i messed up at?
Code:
  
on *:text:*:#:{
  if ($1 == !riddleoff) {
    if !%rdl {
      msg # It's not on
    }
    else {
      describe # 9,1¿3,1? 9,1R3,1i9,1d3,1D9,1l3,1e 9,1M3,1e 9,1T3,1h9,1i3,1S 9,1?3,1¿ has been turned off.
      riddle.end
    }
  }
  if ($1 == !riddle) {
    if !%rdl {
      new.riddle #
    }
    else {
      describe # ¿? %riddle ?¿
    }
  }
  else {
    if ($1- == %answer) {
      describe # %answer $+ !¡! Congratulations $nick you are correct!
      unset %rdl
      describe # Type !riddle for another round.
      .timer.riddle.end.turn off
    }
    else {
      if %rdl {
        .notice $nick Sorry $nick $+ , that's wrong.
        else {
          halt
        }
      }
    }
  } 
} 
alias new.riddle {
  set %rdl 1
  set %read $read(riddle.txt)
  set %answer $gettok(%read,2-,61)
  set %riddle $gettok(%read,1,61)
  describe $1 9,1¿3,1? 9,1R3,1i9,1d3,1D9,1l3,1e 9,1M3,1e 9,1T3,1h9,1i3,1S 9,1?3,1¿
  describe $1 :: %riddle ::
  .timer.riddle.end.turn 1 60 riddle.end.turn $1
}
alias  riddle.end.turn {
  describe $1 Time's up the answer was %answer
  describe $1 Put your Thinking Caps on Brainiacs!
  new.riddle $1
}
alias riddle.end {
  unset %rdl
  .timer.riddle.end.turn off
}

Posted By: DaveC Re: Acronym Game - 27/03/05 10:03 AM
One thing I did is rename the variables, they all start with %rdl. now this is so they are unlikely to conflict with any other variable names other scripts may use.
* I changed if ($1 == !riddle) { into elseif ($1 == !riddle) { becuase before if !riddleoff after doing its code it is also compared to %rdl.answer etc
* Only enter the comparing to %rdl.answer code if %rdl.on is set, if its not there isnt a riddle in play, otherwise just ignore the text
* If the answer was correct, I call the end.riddle alias (reduces code, also means if u patch the code u only need to patch it in one place)
* I changed set %read $read(riddle.txt) to var %read = $read(riddle.txt) meaning it exists only while the script (event) is running
.. You might notice i didnt bother to make it %rdl.read as this variable exists only inside this script, if a $read exists elsewhere it is uneffected.

Code:
on *:text:*:#:{
  if ($1 == !riddleoff) {
    if !%rdl.on {
      msg # It's not on
    }
    else {
      describe # 9,1¿3,1? 9,1R3,1i9,1d3,1D9,1l3,1e 9,1M3,1e 9,1T3,1h9,1i3,1S 9,1?3,1¿ has been turned off.
      riddle.end
    }
  }
  elseif ($1 == !riddle) {
    if !%rdl.on {
      new.riddle #
    }
    else {
      describe # ¿? %rdl.riddle ?¿
    }
  }
  elseif (%rdl.on) {
    if ($1- == %rdl.answer) {
      describe # %rdl.answer $+ !¡! Congratulations $nick you are correct!
      describe # Type !riddle for another round.
      riddle.end
    }
    else {
      .notice $nick Sorry $nick $+ , that's wrong.
    }
  } 
} 
alias new.riddle {
  set %rdl.on 1
  var %read = $read(riddle.txt)
  set %rdl.answer $gettok(%read,2-,61)
  set %rdl.riddle $gettok(%read,1,61)
  describe $1 9,1¿3,1? 9,1R3,1i9,1d3,1D9,1l3,1e 9,1M3,1e 9,1T3,1h9,1i3,1S 9,1?3,1¿
  describe $1 :: %rdl.riddle ::
  .timer.riddle.end.turn 1 60 riddle.end.turn $1
}
alias  riddle.end.turn {
  describe $1 Time's up the answer was %rdl.answer
  describe $1 Put your Thinking Caps on Brainiacs!
  new.riddle $1
}
alias riddle.end {
  unset %rdl.on
  unset %rdl.answer
  unset %rdl.riddle
  .timer.riddle.end.turn off
}
;
;riddle.txt format &lt;riddle&gt;=&lt;answer&gt; ie:
;Whats black and white and red all over=newspaper
;Why did the chicken cross the road=To get to the other side
;
Posted By: Pariah Re: Acronym Game - 28/03/05 05:27 AM
Is it possible for me to use %acr $+(.,$nick) or something like that so i could set up some kind of points? Like whenever a person gets an answer right it will inc the variable by 1
Posted By: Pariah Re: Acronym Game - 28/03/05 08:06 AM
Another thing ive noticed from playing around with the acronym game, is that after a user guesses the correct answer, if anyone says it after them it says congratulations to them too. I really hate to ask you guys for more help since you've helped me so much already, but it's greatly appreciated.
Posted By: DaveC Re: Acronym Game - 28/03/05 12:48 PM
If thats the case, then I think you have altered something, becuase I tested it out and that didnt happen, (%rdl.on) must be set, and when someone gets win messaged it gets unset.

---

%acr $+(.,$nick) this isnt the correct format!

Ill break down whats it is...

$+(%,arc.,$nick) this builds the string "%arc.$nick", of course $nick isnt "$nick" but the usersname

Now if you want to set a value to it its /SET $+(%,arc.,$nick) valuehere
Now if you want to var a value to it its /VAR $+(%,arc.,$nick) = valuehere

But if you want to access the value of %arc.$nick then you must use $($+(%,arc.,$nick),2) or add a $( ... ,2) around it essentially.
This means evaluate it 2 times, once gets the "%arc.$nick the second time the contents of that!
© mIRC Discussion Forums