Jump to content

Trivia script


Recommended Posts

Some fo you may now the mirc trivia script. Its a game which asks you a question and the first one in the channel who gives the answer gets points. Now, i somethimes play this with some people on irc and i recently found the list of questions the script is using. And i am trying to write a program to look up the answer to a question real quick. it gives a box in which you can type a part of the question and then it starts searching for the line the question is on. When found it splits the answer from the question (the answer is on the same line, seperated from the question by an *), copies the answer to the clipboard and gives a beep to let me know i can paste in in my mirc screen. But now my problem is, it searches way too slow, it takes minutes and you only have 30 seconds to answer, i just waited about 4 minutes and the program didnt come up with an answer. What can i do to make it go faster? Thanks in advance :)

btw, this is what the question list looks like, but the real one has thousands of questions: (sorry its in dutch)

wat maakte renault in woi dat op rupsbanden langzamer reed dan een soldaat kon lopen*tanks

wat meet een evaporimeter*verdamping

wat met een display van vloeibare kristallen hebben 600 miljoen mensen tegen het jaar 2000 op zak *mobiele telefoon

wat mocht in nederland in 1982 voor het eerst gedragen worden bij voetbalwedstrijden*voetbalshirts met reclame

HotKeySet("+{f3}", "findanswer") 

while 1
    sleep(100)
WEnd

Func findanswer()
    $line = 0
    $vraag = InputBox ("Vraag","Type een deel van de vraag")
    while 1
        $line = $line + 1
        $string = FileReadLine("trivia.txt",$line)
        if StringInStr($string,$vraag) Then
            $stringsplitted = StringSplit($string,"*",1)
            ClipPut($stringsplitted[2])
            beep(500,1000)
            ExitLoop
        EndIf
    WEnd
EndFunc
Link to comment
Share on other sites

  • 3 weeks later...

Not tested:

HotKeySet("+{f3}", "findanswer") 

while 1
    sleep(100)
WEnd

Func findanswer()
    $vraag = InputBox ("Vraag","Type een deel van de vraag")
    $data = StringSplit(FileRead("trivia.txt"),@CRLF,1)
    For $i = 1 To $data[0]
        $string = $data[$i]
        if StringInStr($string,$vraag) Then
            $stringsplitted = StringSplit($string,"*",1)
            ClipPut($stringsplitted[2])
            beep(500,1000)
            ExitLoop
        EndIf
    Next
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...