mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 20
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 20
I have a text file that someone gave me with riddle in it. When a user types riddle or !riddle, I want to pull the riddle and theh answer from the file.

The file is currently laid out so that each riddle takes two lines...the first line is the riddle, the second the answer.

When the user type riddle (or !riddle, I want to pull the riddle...wait about 3 seconds then have the answer put out.

How would I do that..or is it even possible,

Thanks for your help. cool


Scott Roberts
T&R Communications of Florida
sroberts@tnrcomm.com
Joined: Dec 2002
Posts: 83
A
Babel fish
Offline
Babel fish
A
Joined: Dec 2002
Posts: 83
Try something like:
(You need to mark every riddle line to start with: Riddle
Code:
 
on *:TEXT:!riddle:*:{
/msg $nick $read(riddle.txt, s, Riddle)
/timer 1 10 /msg $nick $read(riddle.txt, $calc($readn + 1))
}
 


Not tested, but that should do the trick.

riddle.txt should be setup like:
Riddle This is the actual riddle
Answer to riddle

(ty collective)

Last edited by acemiles_ed; 23/12/02 04:44 AM.
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
That would be on TEXT, not on TEST smile

Joined: Dec 2002
Posts: 20
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 20
Okay..that works, but what if I have more than one riddle in a file? Would I just be best to have the riddle and answer on one line, it can it randomly pull from the ODD numbered lines in the file to get the riddle and hten the Even number to get the answer....I may be asking too much....


Scott Roberts
T&R Communications of Florida
sroberts@tnrcomm.com
Joined: Dec 2002
Posts: 83
A
Babel fish
Offline
Babel fish
A
Joined: Dec 2002
Posts: 83
Well... if you add the word "Riddle" in front of every riddle... that script should randomly pick any line starting with Riddle. It will then wait 10 secs to /msg the answer (which is on the next line)

Joined: Dec 2002
Posts: 332
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 332
perhaps you could make another .txt file for the answers and use the $readn to call the answer from there ?
for instance
Code:
 
 
 on *:TEXT:!riddle:*:{
/msg $nick $read(riddle.txt)
/timer 1 10 /msg $nick $read(amswer.txt,$readn)
}
 


that would read a randome line from riddles.txt and then read the coresponding line in answer.txt but riddle 1 and answer 1 would have to each be on line one of thier respective files .
i havent tested it but it should work

Joined: Dec 2002
Posts: 332
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 332
with the s switch in the $read command line would it pull a random line or the first line with riddle in it ? havent used it much just curious ? i was of the thinking it would always hit the first line starting with riddle ?

Joined: Dec 2002
Posts: 83
A
Babel fish
Offline
Babel fish
A
Joined: Dec 2002
Posts: 83
Cheech brought up a good point.. using the s switch, it would always pull the first one it found =/

His idea of putting them into two files in theory would work. Just make sure you have the answer and the question on the same corresponding line.

Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Cheech is right, it does only hit the first line..

Code:
on *:TEXT:!riddle:#:{
  var %riddle = $read(riddle.txt)
  if ( $right($readn,1) == 0 ) || ( $right($readn,1) == 2 ) || ( $right($readn,1) == 4 ) || ( $right($readn,1) == 6 ) || ( $right($readn,1) == 8 ) {
    set %answer %riddle
    set %question $read(riddle.txt,$calc($readn - 1))
  }
  else {
    set %question %riddle
    set %answer $read(riddle.txt,$calc($readn + 1))
  }
  msg # Riddle: %question
  .timer 1 10 msg # Answer: %answer
}


^That will work. Riddles need to be on odd numbered lines, and the answers on the even ones after them.


Link Copied to Clipboard