mIRC Home    About    Download    Register    News    Help

Print Thread
#80417 24/04/04 08:13 AM
Joined: Apr 2004
Posts: 6
F
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
F
Joined: Apr 2004
Posts: 6
Hi. I am a trivia addict. I have Tat's Trivia Bot installed and it work perfectly in my channel. Is there any possible way I can play trivia offline on my laptop just by myself? It would be useful to study for tests.

Thanks

fifa

#80418 24/04/04 03:17 PM
Joined: Sep 2003
Posts: 98
N
Babel fish
Offline
Babel fish
N
Joined: Sep 2003
Posts: 98
there is always a way smile
edit the script so it wont msg to anyone or to any chan but insted use echo.


www.stwar.us.to
IRCnet - #stwar
#80419 24/04/04 03:41 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

I'm afraid its more complex as you portray, since that trivia bot uses ON TEXT events, whilst you cannot use that online.

He'll have to make an ON INPUT event.

Basically, if you're not experienced in scripting, then it is a lost cause to try to edit that trivia bot yourself. I havent seen the code, but as i made an RPGTrivia myself (knowing how advanced and big it can get), i know that you will most likely get lost in all the coding, trying to change online events to offline events.

Of course it depends on how sophisticated and advanced you want this trivia to be. If all you're asking for is the most simplistic trivia that just asks questions at regular intervals, then this can be scripted easily, with basic mirc scripting knowledge.

Who knows, maybe you will find some pre-made offline trivia bots here

Greetz

Last edited by FiberOPtics; 24/04/04 05:10 PM.

Gone.
#80420 24/04/04 04:58 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

I couldnt resist it, so i went ahead and made u this offline trivia bot. As you will see it is the most basic thing, with a minimal of features lol. The trivia will appear in your Status Window.

**** Read this before using ****

Before running the bot, you have to create a text file called: questions.txt which you have to put in your main mirc folder.
In this file, put your questions and answers in the following syntax: question~answer

For example:
who am i~fiberoptics
what is my favorite color~blue
how do you say "four" in japanese~shi or yon

Note: do not use the '~' character in a question or answer, as it is needed to seperate the questions from
the answers!!!

Note: make sure you add more than 5 questions before starting the script! I've added a piece of code
where the script will check if a question has been asked within the last 5 times. If it has, then it will ask another
question instead. You can change this number of repetitions by changing the variable %trivia.rep in the alias trivia.load

Note: you are free to make whatever change u want to make the colors and the way text is presented much nicer. I just
provided the structure, up to you to make it fancy smile

Note: In the alias trivia.load you will find some variables like:

set %trivia.rep 5 <--- sets how many questions you want to be asked before a previously asked question is re-asked
set %trivia.avaltime 60 <---- sets the amount of seconds you have to answer a question correctly
set %trivia.interval 10 <--- sets the amound of seconds until a new question is asked after the last question is finished

---> You can change these values to your likings.

Note: There are only 4 commands available:
1) /trivia.load
2) /trivia.unload
3) !hint
4) !!hint

As you will see when the trivia is running, when a question is asked, it will give u a small hint as follows: all letters will be replaced by *. For example: trivia turns into --> ******

The second type of hint is triggered when u type !hint. The script will only show the vowels from the answer. For example: trivia turns into ---> **i*ia

The third type hint is triggered when u type !!hint. The script will then show you all letters but in scrambled order. For example: trivia turns into something like ---> airtvi

*****************

Put the following code in a new remote file (and don't forget to make sure questions.txt is in you mirc directory with atleast 5 questions in it)

To start up the bot type /trivia.load
To stop the bot type /trivia.unload

Code:
on *:INPUT:*:{
  if (/* !iswm $1) {
    if ($active == status window) { haltdef | echo -s $+(&lt;,$me,&gt;) $1- }
    if (%trivia.status == on) {
      if (%trivia.answer == $strip($1-)) trivia.win $ifmatch 
      elseif ($1 == !hint) trivia.echo Second Hint: $hint(%trivia.answer).2
      elseif ($1 == !!hint) trivia.echo Third Hint: $hint(%trivia.answer).3
    } 
  }
}

alias trivia.echo { echo -s 04&lt;Trivia&gt; 10 $+ $1- }

alias trivia.win {
  var %time = $calc(($ticks - %trivia.ticks) / 1000)
  var %wpm = $ceil($calc(($len(%trivia.answer) / %time) * 12))
  inc %trivia.streak 
  trivia.echo &lt;&lt; $me &gt;&gt; found the right answer &lt;&lt; %trivia.answer &gt;&gt; in %time seconds, and average WPM of %wpm
  trivia.echo $me has won %trivia.streak times in a row
  trivia.nextQ
}

alias trivia.nextQ {
  %trivia.status = off
  .timertrivia.failQ off 
  .timertrivia.askQ 1 %trivia.interval trivia.askQ
  trivia.echo Next question coming in %trivia.interval seconds, get ready!
  trivia.echo $chr(160)
}

alias trivia.failQ {
  %trivia.streak = 0 
  trivia.echo You didn't find the right answer: %trivia.answer
  trivia.nextQ
}

alias trivia.askQ {

  :begin
  var %data = $read(%trivia.questions)
  var %number = $readn

  if ($istok(%trivia.repeat,%number,46)) goto begin 
  %trivia.repeat = $addtok(%trivia.repeat,%number,46)
  if ($numtok(%trivia.repeat,46) &gt; %trivia.rep) %trivia.repeat = $deltok(%trivia.repeat,1,46) 

  tokenize 126 %data

  %trivia.status = on
  %trivia.answer = $2
  %trivia.ticks = $ticks

  .timertrivia.failQ 1 %trivia.avaltime trivia.failQ 

  trivia.echo Question $chr(35) $+ %number - $1 ?
  trivia.echo First hint: $hint($2).1
  trivia.echo $chr(160)
}

alias hint {
  if ($prop == 1) {
    var %t = $chr(42)
    return $lower($replace($1-,a,%t,b,%t,c,%t,d,%t,e,%t,f,%t,g,%t,h,%t,i,%t,j,%t,k,%t,l,%t,m,%t,n,%t,o,%t,p,%t,q,%t,r,%t,s,%t,t,%t,u,%t,v,%t,w,%t,x,%t,y,%t,z,%t,0,%t,1,%t,2,%t,3,%t,4,%t,5,%t,6,%t,7,%t,8,%t,9,%t))
  }
  elseif ($prop == 2) {
    var %t = $chr(42)
    return $lower($replace($1-,b,%t,c,%t,d,%t,f,%t,g,%t,h,%t,k,%t,l,%t,m,%t,n,%t,p,%t,q,%t,r,%t,s,%t,t,%t,v,%t,w,%t,x,%t,y,%t,z,%t,1,%t,2,%t,3,%t,4,%t,5,%t,6,%t,7,%t,8,%t,9,%t))
  }
  elseif ($prop == 3) {
    tokenize 32 $1-

    var %x = 1
    var %word, %newword, %comma, %hint

    while (%x &lt;= $0) { 

      %word = $ [ $+ [ %x ] ]
      if ($right(%word,1) == $chr(44)) { %comma = $ifmatch | %word = $left(%word,-1) }

      while ($len(%word)) {

        if ($rand(1,2) == 1) %newword = $right(%word,1) $+ %newword 
        else %newword = %newword $+ $right(%word,1) 
        %word = $left(%word,-1) 
      }
      %hint = %hint %newword $+ %comma
      %newword = $null
      %comma = $null
      inc %x
    }
    return $lower(%hint)
  }
}

alias trivia.load {
  set %trivia.questions $+(",$scriptdir,questions.txt,")
  set %trivia.rep 5
  set %trivia.status off
  set %trivia.avaltime 60
  set %trivia.interval 10
  .timertrivia.askQ 1 10 trivia.askQ
  trivia.echo Trivia starting in 10 seconds, get ready!
}

alias trivia.unload {
  unset %trivia.*
  .timertrivia.* off
  trivia.echo Trivia has been fully stopped. Type /trivia.load to start it back up.
} 


Here's what it looks like:
<Trivia> Question #3 - how do you say "four" in japanese ?
<Trivia> First hint: *** ** ***
<Trivia>  
<FiberOPtics> !hint
<Trivia> Second Hint: **i o* *o*
<FiberOPtics> !!hint
<Trivia> Third Hint: sih or yno
<FiberOPtics> shi or yon
<Trivia> << FiberOPtics >> found the right answer << shi or yon >> in 8.329 seconds, and average WPM of 15
<Trivia> FiberOPtics has won 3 times in a row
<Trivia> Next question coming in 10 seconds, get ready!
<Trivia>  

Enjoy cool


Last edited by FiberOPtics; 24/04/04 05:46 PM.

Gone.
#80421 24/04/04 06:57 PM
Joined: Sep 2003
Posts: 98
N
Babel fish
Offline
Babel fish
N
Joined: Sep 2003
Posts: 98
WOW FiberOPtics! you really have time smile


www.stwar.us.to
IRCnet - #stwar
#80422 24/04/04 07:01 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hehe,

didn't take me that long (20 mins) but yeah I got a lot of free time since its Saturday.

Greetz


Gone.
#80423 24/04/04 10:20 PM
Joined: Apr 2004
Posts: 6
F
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
F
Joined: Apr 2004
Posts: 6
FiberOptics. Wow! I appreciate all the efforts you put into scripting me a bot.

I figured it out. Thanks alot! It a beautiful bot. wink

Have a great day!

fifa

Last edited by fifa2oo2; 24/04/04 11:53 PM.
#80424 25/04/04 12:32 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

you're welcome, and don't be shy to ask any questions about the script.
I remember a time where I would have asked the same thing.
I'll explain the steps you need to take to get the bot working.

Should you run into problems trying to get the script working, then i'll just send u an email with the script, and with a simple command to load it grin

1) Assuming you are using a Windows OS, go to 'Start' --> 'Run', and type in the following: wordpad.exe
Click on 'Ok', and then the Wordpad program will open.

Now copy paste the code at the bottom of THIS post to wordpad. This is necessary, as if you would paste it in mirc directly,
it would not respecte the new lines.


2) Leave Wordpad as it is for now, and go to mirc, and in Mirc, do alt+r so that it takes you to the Scripts Editor.
Now click on 'File' in the Scripts Editor, and click on New.
This will create a new scripts file.


3) Copy the code that you pasted in wordpad, from wordpad to this mirc scripts editor.
When you've pasted it, click on the button {} in the upper right of the Scripts Editor, which will sort the code more nicely.


4) Click on 'File' in the scripts editor, and click on 'Save as'. It will ask you to save the script in your mirc folder.
You can choose a name for the script like offlinetrivia.ini
Click on 'Save', and then just close the scripts editor by clicking on 'Ok'.


5) create a .txt file in your mirc folder, named questions.txt, and put in the questions to your liking.
Beware as stated before, you have to add in atleast 5 questions before trying to run the trivia as it will freeze otherwise.


6) when you have your questions.txt file ready, just save it and close it, and now you are ready to play trivia.


7) in your status window, simply type /trivia.load and this will start the trivia. To stop the trivia, type /trivia.unload


By the way I've made some changes to the code that i posted earlier to make it look better, so use the following code instead of the other one.

Code:
 
on *:INPUT:*:{
  if (/* !iswm $1) {
    if ($active == status window) { haltdef | echo -a $+(&lt;,$me,&gt;) $1- }
    if (%trivia.status == on) {
      if (%trivia.answer == $strip($1-)) trivia.win $ifmatch 
      elseif ($1 == !hint) trivia.echo Second Hint: $trivia.hint(%trivia.answer).2
      elseif ($1 == !!hint) trivia.echo Third Hint: $trivia.hint(%trivia.answer).3
    } 
  }
}

alias -l trivia.echo { echo -s $replace(&lt;Trivia&gt; $1-,,10,,07,,04) } 

alias -l trivia.win {
  var %time = $calc(($ticks - %trivia.ticks) / 1000)
  var %wpm = $ceil($calc(($len(%trivia.answer) / %time) * 12))
  inc %trivia.streak 
  trivia.echo [ $+ $me found the right answer &lt;&lt; %trivia.answer &gt;&gt; in %time seconds, and average WPM of %wpm $+ ]
  trivia.echo [ $+ $me has won %trivia.streak times in a row]
  trivia.nextQ
}

alias -l trivia.nextQ {
  %trivia.status = off
  .timertrivia.failQ off 
  .timertrivia.askQ 1 %trivia.interval trivia.askQ
  trivia.echo [Next question coming in %trivia.interval seconds, get ready]
  trivia.echo $chr(160)
}

alias -l trivia.failQ {
  %trivia.streak = 0 
  trivia.echo [You didn't find the right answer: %trivia.answer $+ ]
  trivia.nextQ
}

alias -l trivia.askQ {

  :begin
  var %data = $read(%trivia.questions)
  var %number = $readn

  if ($istok(%trivia.repeat,%number,46)) goto begin 
  %trivia.repeat = $addtok(%trivia.repeat,%number,46)
  if ($numtok(%trivia.repeat,46) &gt; %trivia.rep) %trivia.repeat = $deltok(%trivia.repeat,1,46) 

  tokenize 126 %data

  %trivia.status = on
  %trivia.answer = $2
  %trivia.ticks = $ticks

  .timertrivia.failQ 1 %trivia.avaltime trivia.failQ 

  trivia.echo Question $chr(35) $+ %number - $1 ?
  trivia.echo First hint: $trivia.hint($2).1
  trivia.echo $chr(160)
}

alias -l trivia.hint {
  if ($prop == 1) {
    var %t = $chr(42)
    return $lower($replace($1-,a,%t,b,%t,c,%t,d,%t,e,%t,f,%t,g,%t,h,%t,i,%t,j,%t,k,%t,l,%t,m,%t,n,%t,o,%t,p,%t,q,%t,r,%t,s,%t,t,%t,u,%t,v,%t,w,%t,x,%t,y,%t,z,%t,0,%t,1,%t,2,%t,3,%t,4,%t,5,%t,6,%t,7,%t,8,%t,9,%t))
  }
  elseif ($prop == 2) {
    var %t = $chr(42)
    return $lower($replace($1-,b,%t,c,%t,d,%t,f,%t,g,%t,h,%t,k,%t,l,%t,m,%t,n,%t,p,%t,q,%t,r,%t,s,%t,t,%t,v,%t,w,%t,x,%t,y,%t,z,%t,1,%t,2,%t,3,%t,4,%t,5,%t,6,%t,7,%t,8,%t,9,%t))
  }
  elseif ($prop == 3) {
    tokenize 32 $1-

    var %x = 1
    var %word, %newword, %comma, %hint

    while (%x &lt;= $0) { 

      %word = $ [ $+ [ %x ] ]
      if ($right(%word,1) == $chr(44)) { %comma = $ifmatch | %word = $left(%word,-1) }

      while ($len(%word)) {

        if ($rand(1,2) == 1) %newword = $right(%word,1) $+ %newword 
        else %newword = %newword $+ $right(%word,1) 
        %word = $left(%word,-1) 
      }
      %hint = %hint %newword $+ %comma
      %newword = $null
      %comma = $null
      inc %x
    }
    return $lower(%hint)
  }
}

alias trivia.load {
  set %trivia.questions $+(",$scriptdir,questions.txt,")
  set %trivia.rep 4
  set %trivia.status off
  set %trivia.avaltime 60
  set %trivia.interval 10
  .timertrivia.askQ 1 10 trivia.askQ
  trivia.echo [Trivia starting in 10 seconds, get ready]
}

alias trivia.unload {
  unset %trivia.*
  .timertrivia.* off
  trivia.echo [Trivia has been fully stopped. Type /trivia.load to start it back up]
} 


You will notice this alias called
alias -l trivia.echo { echo -s $replace(<Trivia> $1-,,10,,07,,04) }

You can change the colors here to your likings, and it will totally change the way the trivia looks, as this is the central point.
Setting a different color here will make it use this color everywhere in the trivia script. so you could change 10 to another color number, to your likings.

If you want some more features to be added for this trivia, just let me know, i can script it fairly fast, depending on what you are asking.

Greetz, and enjoy!


Gone.
#80425 25/04/04 12:51 AM
Joined: Apr 2004
Posts: 6
F
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
F
Joined: Apr 2004
Posts: 6
FiberOptics,

Hi. I followed the instructions and it worked perfectly now. *one bow to the master* grin
I was in #mircscripting on undernet and they were very helpful.

Anyway, I know that notepad does not support more advance features like supercript/subscript and greek characters (alpha, beta, lambda, etc..) that Mircrosft Word does. So some one in #mircscripting suggest Hash Tables. I look at the information in /help /hadd and wow! I am lost.

Is it possible for trivia to use the questions from questions.doc rather than questions.txt? Can you add this feature for me?

Hope to hear back from you,

thanks!

laugh

#80426 25/04/04 01:28 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hmm,

well the odd characters are definitely a problem, not only to store the questions/answers which contain these odd characters, but also simply mirc not showing them. E.g. if i paste the alpha symbol from word to Mirc, mirc translates it to a regular a.

I don't know much of fonts in general or mirc, so I suppose its best to ask this in the mirc help section, as it is not really related to scripting. But you should try to find out which font supports those weird characters.

Btw, suppose that we find a solution..there is still the matter of having to type those odd characters in mirc. I don't have alpha or beta or greek characters on my keyboard, so how would u type these things in mirc if e.g. an answer to a question involves greek characters?

As for the retrieving of text from .doc files. Personally i don't know how to do that...I havent gotten into COM scripting yet, but I think it should be possible to read lines from a .doc file using COM. Though I cannot (yet) help you with that, as it involves non-regular mirc commands which i'm not familiar with (I'm not a programmer, i study Economics :tongue:)

Hash tables do not help the problem, as they will have to load the questions from a file first, and the whole problem is storing those weird characters in a file. I've tried to /hload a .doc file into a hash table, and the result was pretty ugly :tongue:

Anyway, I'm way too tired right now to be thinking clearly, so I'll read this thread again tomorrow lol.

Good luck,

Greetz



Gone.
#80427 25/04/04 09:22 PM
Joined: Apr 2004
Posts: 6
F
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
F
Joined: Apr 2004
Posts: 6
FiberOptics,

You are right. It would be a problem with greek characters not being on the keyboard. Lets scratch out that feature. hehe. This is the last feature request, honestly: Can you make trivia count an answer I typed as right if the spelling is say...
1.80% correct
2. allows 1 or two letters wrong
3. and it ignores spacing?

For example,
Where do I live~Helsinki, Finland

So if I answered the question above "Where do I live?" with the reply :

Helsinki, Finnland (spelling error here)
Helsinki,Finland (space between comma and Finland)

Trivia would count either as correct answers.

Any one of the feature would be great. I know I am a beggar here, so I can't choose. If you have the time and eager to add this feature, it would be great. I am happy with the trivia bot you wrote already. I am definitely going to learn more about scripting.

Thanks!

fifa





#80428 26/04/04 12:42 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

regarding your suggestions:

the suggestoin regarding ignoring spaces is very easy and goes as follows:
Code:
 
on *:INPUT:*:{
  if (/* !iswm $1) {
    if ($active == status window) { haltdef | echo -a $+(&lt;,$me,&gt;) $1- }
    if (%trivia.status == on) {
      var %text = $remove($strip($1-),$chr(32))
      if (%text == $remove(%trivia.answer,$chr(32))) trivia.win 
      elseif ($1 == !hint) trivia.echo Second Hint: $trivia.hint(%trivia.answer).2
      elseif ($1 == !!hint) trivia.echo Third Hint: $trivia.hint(%trivia.answer).3
    } 
  }
} 


So just replace this on input event with the former one, and then the script will totally ignore all spaces.

So if the answer to a question is: i live in helsinki then it will even trigger as correct if you type: iliveinhelsinki

As for the other 2 suggestions: I cannot script those, because it involves complex string matching, where u need a difficult algorithm to compare a string containing multiple words with another strong containing multiple words. It's not a pickle to script that in say 10 mins lol.

Besides, picture this possible answer: from point a to x and then all the way to z

If you allow 1 or two false letters, then the following answer would be correct: from point z to f and then all the way to z

You see where I'm going with this, hehe.

Nevertheless, I have a strong suspicion that someone with decent regex skills could come up with something, but my knowledge simply doesnt reach that far yet.

I'm planning to study "Informatics/Programming" after I get my "Applied Economic Science" degree, so who knows, maybe in 2 years from here I'll be able to script those suggestions for you grin

Good luck!



Gone.
#80429 27/04/04 04:11 PM
Joined: Apr 2004
Posts: 6
F
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
F
Joined: Apr 2004
Posts: 6
Thanks Fiber! You've done plenty enough already. I love the bot. I wish you the best of luck in getting both degrees the sooner the better (esp. the second one). hehe.

Have a great day!

fifa

#80430 27/04/04 04:42 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
You are welcome!

Have fun playing trivia,

Greetz


Gone.
#80431 05/10/06 04:40 AM
Joined: Apr 2004
Posts: 6
F
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
F
Joined: Apr 2004
Posts: 6
FiberOptics!

How are you doing?! Its been a very long time. I am still using the trivia bot you wrote! Thanks

Fifa

fifa2oo2 #205418 22/10/08 06:25 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi fifa,

I'm doing fine thanks. Very busy with work!!! I stopped scripting when I graduated from university and got a full time job.

It was a great time on IRC and especially mIRC scripting.

Great that you're still enjoying the offline trivia. I think it was made when I just started out scripting, I'm sure the code can be improved! Hahaha...

Take care,
Dieter


Gone.

Link Copied to Clipboard