mIRC Home    About    Download    Register    News    Help

Print Thread
#62682 03/12/03 04:04 AM
Joined: Nov 2003
Posts: 84
S
Static Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Nov 2003
Posts: 84
Im trying to write a test script kinda like the trivia bots but for a single person and in private. I have written it but its a static set of questions. Id like some input on how to randomize it a little. Any help will be greatly appreciated.


chat.irchat.tv
#Help #Trivia #Scripts
Co-Admin @ IRChat.tv
#62683 03/12/03 04:23 AM
Joined: Nov 2003
Posts: 227
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Nov 2003
Posts: 227
Putting all the questions in a text file sounds like a good plan, then you can use $read(filename.txt) to read a random line from the file.

#62684 03/12/03 04:25 AM
Joined: Nov 2003
Posts: 84
S
Static Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Nov 2003
Posts: 84
That would work but how would I then know if they answered right? How would I even set answers?


chat.irchat.tv
#Help #Trivia #Scripts
Co-Admin @ IRChat.tv
#62685 03/12/03 04:56 AM
Joined: Nov 2003
Posts: 227
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Nov 2003
Posts: 227
well you would need to put the random line into a global variable like:

set %something $read(questions.txt)

you could have the question and answer in the file seperated with a token say. answer : question
the answer to the question will be $gettok(%something,1,58) and the question will be $gettok(%something,2,58)

when you are ready for the next question just read the file again and set the variable to the new line.

you will have to make sure that the questions or answers don't contain any extra :'s




#62686 03/12/03 05:03 AM
Joined: Nov 2003
Posts: 84
S
Static Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Nov 2003
Posts: 84
So then set the $gettok(%something,2,58) to another variable? and $gettok(%something,1,58) to one ? like
/set %question $gettok(%something,2,58)
/set %answer $gettok(%something,1,58)
.msg %tester %question
then have a on text?
on 1:text:*:?: {
if (%answer == $1-) /whatever here
}
Like that? sorry if I sound noobish its late lol


chat.irchat.tv
#Help #Trivia #Scripts
Co-Admin @ IRChat.tv
#62687 03/12/03 05:23 AM
Joined: Nov 2003
Posts: 227
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Nov 2003
Posts: 227
I don't know how you want to trigger it but:

var %temp = $read(questions.txt)
; this only needs to be held in a local var
set %answer $gettok(%temp,1,58)
set %question $gettok(%temp,2,58)
; these will need to be held in global vars, hence the set

now you have a random question in %question, and the answer to that question held in %answer. you can now
msg namename %question
and check if the reply is equal to %answer, you may wish to set a few other vars to make sure the nick who answers the question is the same nick that you asked the question to.

#62688 03/12/03 06:17 AM
Joined: Nov 2003
Posts: 84
S
Static Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Nov 2003
Posts: 84
Im at that so far this is extremly base line stuff, but It wont stop asking questions after 5 and say the points?
Code:
 on 1:text:!Test:?: {
  /set %tester $nick
  /set %something $read(questions.txt)
  /set %answer $gettok(%something,1,58)
  /set %question $gettok(%something,2,58)
  /question
}
on 1:text:*:?: {
  if (%answer == $1) {
    ./msg %tester Good Guess | /inc %points | /question
  }
  elseif (%answer != $1) {
    ./msg %tester Good Guess | /question
  }
}
alias question {
  if (%question.num == 5) { haltdef } ./msg %tester You received %points point(s)
  /inc %question.num 1  
  /set %something $read(questions.txt)
  /set %answer $gettok(%something,1,58)
  /set %question $gettok(%something,2,58)
  ./msg %tester %question
}
 

Last edited by Static; 03/12/03 06:22 AM.

chat.irchat.tv
#Help #Trivia #Scripts
Co-Admin @ IRChat.tv
#62689 03/12/03 07:12 AM
Joined: Nov 2003
Posts: 84
S
Static Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Nov 2003
Posts: 84
Whelp I got it thanks tho, if anyone has better ideas or suggestions please let me know.


chat.irchat.tv
#Help #Trivia #Scripts
Co-Admin @ IRChat.tv
#62690 03/12/03 07:28 AM
Joined: Nov 2003
Posts: 227
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Nov 2003
Posts: 227
looks good smile , but there are somethings that I should just point out.

This:

on 1:text:*:?: {
if (%answer == $1) {
./msg %tester Good Guess | /inc %points | /question
}
elseif (%answer != $1) {
./msg %tester Good Guess | /question }
}
I would make:
on 1:text:*:?:{
if ($nick == %tester) {
if ($1- == %answer) {
.msg $nick Good Guess | inc %points | question
}
else {
.msg $nick <Comment for wrong answer> | question
}
}
}
note: this check to make sure you are talking with the right person, but still does not allow them to change their nick name, maybe you should use /ialmark for that part. It's up to you, but I'm sure you will get it the way you want.

Just remember you have if (%answer == $1) that only allows the answer to be a single word. $1- would allow multi word answers, and just remember what i said about the global and local variables, set and var are not the same, read /help variables , but these things don't really matter that much.

#62691 03/12/03 08:09 AM
Joined: Nov 2003
Posts: 84
S
Static Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Nov 2003
Posts: 84
I am useing global and I changed it around to lead to an alias that clears them out when the test is over or to end the test if the nick leaves. Also all the answers are in a letter for A B C D I did multiple choice, I also purpesly<sp?> didnt have a you got that wrong, yes the questions are randomized but I didnt want them to know what they got wrong just yet. This is a test to weed out the total n00bs from ths real people that want to be helpers on a network I work with.


chat.irchat.tv
#Help #Trivia #Scripts
Co-Admin @ IRChat.tv
#62692 03/12/03 11:19 PM
Joined: Nov 2003
Posts: 33
Ameglian cow
Offline
Ameglian cow
Joined: Nov 2003
Posts: 33
you dont need to have the 1 after an inc
Code:
 inc %var 1 

just
Code:
 inc %var 

will work


--------------------
I may be insane, but I enjoy it!

Link Copied to Clipboard