Author Topic: trivia ex  (Read 29575 times)

0 Members and 1 Guest are viewing this topic.

Offline c h i l l a

  • Lord
  • ***
  • Posts: 347
  • Karma: +1/-0
trivia ex
« on: 07 January, 2004, 15:13:55 »
my first trivia release.
still very small but lost to come I hope.

Code: [Select]
--Trivia Ex by chill
--Ex = Expert and not experimental, although its still the other way around.
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
trivbot = "RasTriv"
--149
--164
--1
---------------------------------------------------------------------------------------
-- GLOBALS
---------------------------------------------------------------------------------------
RevealChar = strchar(149)
ReggaeTrivQues = {}
QFile = "fullques.txt"
Scores = {}
seeks = {}
Max1 = 10
GetQues = 1
trivtimerset = { 0,0,0 }
curTriv = 0
curCat = ""
curQues = ""
curAnswer = ""
TrivFolder = "txt"
TrivPrefix = "+"
cmd1 = "score"
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
function Main()
dofile(TrivFolder.."/seeks.txt")
QuestionsTotal = getn(seeks)
dofile(TrivFolder.."/Scores.txt")
SetTimer(25*1000)
StartTimer()
end
---------------------------------------------------------------------------------------
function OnTimer()
foreachi(trivtimerset, function(i,_) trivtimerset[i] = trivtimerset[i] + 1 end)
if trivtimerset[2] >= 3 then
if GetQues == 1 then
WriteScore(Scores, "Scores", "Scores.txt")
if getn(ReggaeTrivQues) == 0 then
GetQuestions(Max1)
end
curTriv = ReggaeTrivQues[1][4]
curCat = ReggaeTrivQues[1][1]
curQues = ReggaeTrivQues[1][2]
curAnswer = ReggaeTrivQues[1][3]
tremove(ReggaeTrivQues,1)
points = 0
curHint = gsub(curAnswer,"(%S)",function (w)  points = points + 1 return(RevealChar) end)
SendQuestion(curCat,curQues,curHint)
trivtimerset[1] = 1
GetQues = 0
end
if trivtimerset[1] > 1 then
curHint = RevealOneChar(curAnswer,curHint)
if curAnswer ~= curHint then
SendQuestion(curCat,curQues,curHint)
else
SendToAll(trivbot,"Okey smokeys it was:  "..curHint)
GetQues = 1
trivtimerset = { 0,0,0 }
end
end
end
end
---------------------------------------------------------------------------------------
function DataArrival(curUser,data)
if (strsub(data,1,1) == "<") then
local _,_,sdata = strfind( data, "%b<>%s(.*)%|$")
if curAnswer and strlower(sdata) == strlower(curAnswer) then
SendToAll(trivbot,"Correct "..curUser.sName.." the answer was \""..curAnswer.."\", You get "..points.." Points.")
Scores[strlower(curUser.sName)] = Scores[strlower(curUser.sName)] or 0
Scores[strlower(curUser.sName)] = Scores[strlower(curUser.sName)] + points
SendToAll(trivbot,"That gives you a total score of "..Scores[strlower(curUser.sName)].." Points.")
trivtimerset = { 0,0,0 }
GetQues = 1
elseif TrivFuncs[strlower(sdata)] then
curUser:SendData(trivbot,TrivFuncs[strlower(sdata)]())
end
end
end
---------------------------------------------------------------------------------------
-- Send a question
---------------------------------------------------------------------------------------
function SendQuestion(curCat,curQues,curHint)
SendToAll(trivbot,"QUESTION - Nr. "..curTriv.." from "..QuestionsTotal.." Questions.\r\n"..
"\t----------------------------------------------------------------------\r\n"..
"\t- Category: "..curCat.."  -  Points:  "..points.."\r\n"..
"\tQUESTION: "..curQues.."\r\n"..
"\tHINT:  "..curHint.."\r\n"..
"\t----------------------------------------------------------------------")
end
---------------------------------------------------------------------------------------
-- Reveal a char
---------------------------------------------------------------------------------------
function RevealOneChar(answer,toreveal)
local Revealed,revealchar,ctoreveal = {},0,toreveal
for i = 1,strlen(toreveal) do
if strsub(toreveal,i,i) == RevealChar then
tinsert(Revealed,i)
end
end
if getn(Revealed) == 0 then
SendToAll(answer.."  "..toreveal)
end
revealchar,toreveal = Revealed[random(getn(Revealed))],""
for i = 1,strlen(answer) do
if i == revealchar then
toreveal = toreveal..strsub(answer,i,i)
else
toreveal = toreveal..strsub(ctoreveal,i,i)
end
end
points = points - 1
return(toreveal)
end
---------------------------------------------------------------------------------------
-- Get a bunch of questions
---------------------------------------------------------------------------------------
function GetQuestions(howmany)
local handle = openfile(TrivFolder.."/"..QFile,"r")
if handle then
for i = 1,howmany do
local num = random(getn(seeks))
seek(handle,"set",seeks[num])
local line = read(handle)
local _,_,cat,ques,ans = strfind(line,"(.*)%$%$(.*)%$%$(.*)")
if cat then
tinsert(ReggaeTrivQues,{cat,ques,ans,num})
end
end
closefile(handle)
end
end
---------------------------------------------------------------------------------------
-- Write Score
---------------------------------------------------------------------------------------
function WriteScore(table, tablename, file)
local handle = openfile(TrivFolder.."/"..file, "w")
write(handle,tablename.." = {\r\n")
for i,v in table do
write(handle,"\t["..format('%q',i).."] = "..v..",\r\n")
end
write(handle,"}")
  closefile(handle)
end
---------------------------------------------------------------------------------------
-- TRIVFUNCS
---------------------------------------------------------------------------------------
TrivFuncs = {
[tostring(TrivPrefix..strlower(cmd1))] = function()
TCopy = {}
for i,v in Scores do
tinsert(TCopy,{i,v})
end
sort(TCopy,function(a,b) return(a[2]>b[2]) end)
local msg = " -- Trivia Scores --\r\n\r\n"
for i = 1,getn(TCopy) do
msg = msg.."\t# "..i.."  -  "..TCopy[i][1].."  Points: "..TCopy[i][2].."\r\n"
end
return msg
end,
}


here is the full one with questions and the seek file.

** edit **
sorry can't, need another host...
may last one sucked anyways. lol.
any ideas.

optimus will you host a 2 mb big file?
« Last Edit: 07 January, 2004, 16:14:23 by c h i l l a »

PtokaX forum

trivia ex
« on: 07 January, 2004, 15:13:55 »

Offline c h i l l a

  • Lord
  • ***
  • Posts: 347
  • Karma: +1/-0
(No subject)
« Reply #1 on: 08 January, 2004, 22:12:41 »
lets see how long this one holds :)

my first trivia bot

http://mitglied.lycos.de/shashamane/

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #2 on: 09 January, 2004, 04:20:24 »
Quote
Originally posted by c h i l l a
lets see how long this one holds :)

my first trivia bot

http://mitglied.lycos.de/shashamane/
gues you found a host, if not just email it 2 me.
got enough space left 2 hold a tiny 2MB file for you.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline *??G??*

  • Member
  • ***
  • Posts: 35
  • Karma: +0/-0
(No subject)
« Reply #3 on: 09 January, 2004, 04:51:23 »
Is there any way to set the game on a timer.  So that after the game is played for so long it will stop for a set amount of time and then starts back up on its own?

+--**T?T?? X???m?**--+   @    titanxtreme.kicks-ass.net

Offline c h i l l a

  • Lord
  • ***
  • Posts: 347
  • Karma: +1/-0
(No subject)
« Reply #4 on: 09 January, 2004, 17:49:28 »
yepp its done :)

and thanks plop...  I will get back to you, as soon as they close this one again ;)

http://mitglied.lycos.de/shashamane/p.scripts/
« Last Edit: 09 January, 2004, 17:50:43 by c h i l l a »

Offline *??G??*

  • Member
  • ***
  • Posts: 35
  • Karma: +0/-0
(No subject)
« Reply #5 on: 11 January, 2004, 02:56:34 »
hmmmm......so i guess there is no way to put this on a timer then.

+--**T?T?? X???m?**--+   @    titanxtreme.kicks-ass.net

Offline lazyj189

  • Forum Ace
  • *****
  • Posts: 81
  • Karma: +1/-0
(No subject)
« Reply #6 on: 11 January, 2004, 07:05:59 »
Ive been running this trivia bot for some time now and it is running quite perfectly.  All users seem quite impressed with the layout and scoring.  still havent had any bugs to report since the last fix.
DivX Dominion Hub Owner
3 years running
DivX Dominion Hub

Offline c h i l l a

  • Lord
  • ***
  • Posts: 347
  • Karma: +1/-0
(No subject)
« Reply #7 on: 11 January, 2004, 14:42:11 »
thanks lazyj189 ;),

*??G??* its on this site,

http://mitglied.lycos.de/shashamane/p.scripts/

and you need to edit the Max7.

Offline D-J Valhala

  • Lord
  • ***
  • Posts: 294
  • Karma: +0/-0
(No subject)
« Reply #8 on: 11 January, 2004, 15:19:10 »
WHY TRIVIA EX ?

-         Stable and fast.

-         Over 90.000 questions, no dupes.

-         Only 5 ? 10 MB memory usage.

-         Works in PM and Main.

 

WHY NOT.

-         It only works with the Questions above.



i can't have my own Questions???

and id you can please post one Questions to see how is the trivia work?
10x m8

CyA all
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

Offline c h i l l a

  • Lord
  • ***
  • Posts: 347
  • Karma: +1/-0
(No subject)
« Reply #9 on: 11 January, 2004, 15:39:57 »
there is a question file on the site...  it works, I know :).

well you could have if they are formatted in the right way. But, there is a problem with the LUA in Ptokax, it doesn't always set the curser to the beginning of a line when, doing a line = read(handle)  thats why I have to create a seek file bofore that, with a standalone lua binary.

Offline Event_Horizon

  • Lord
  • ***
  • Posts: 272
  • Karma: +3/-0
(No subject)
« Reply #10 on: 11 January, 2004, 16:30:10 »
nice bot..... :D :D

could you implement !trivskip for skip a question PLZ

would be nice :)
Greez ????_H???z??
??????????????????

??/v\\ \'?\' ?@?? ???? is Secured by RoboCop? Created by Optimus?

Offline *??G??*

  • Member
  • ***
  • Posts: 35
  • Karma: +0/-0
(No subject)
« Reply #11 on: 12 January, 2004, 03:34:33 »
Thanks Chilla.......keep up the good work.

+--**T?T?? X???m?**--+   @    titanxtreme.kicks-ass.net

Offline Event_Horizon

  • Lord
  • ***
  • Posts: 272
  • Karma: +3/-0
(No subject)
« Reply #12 on: 14 January, 2004, 10:09:44 »
Sup C H I L L A ???

to busy to do some more changes on your Trivia bot??

1st remember !trivskip PLZ ( would be very nice )

2nd about saving scores, this also should be done after stopping the trivbot... I lost few points cause I stoped before the score was saved....

just few ideas
Greez ????_H???z??
??????????????????

??/v\\ \'?\' ?@?? ???? is Secured by RoboCop? Created by Optimus?

Offline c h i l l a

  • Lord
  • ***
  • Posts: 347
  • Karma: +1/-0
(No subject)
« Reply #13 on: 14 January, 2004, 10:36:25 »
sometimes I don't post, updates here, so you need to check the site for yourself.

enjoy :)


Trivia EX
« Last Edit: 14 January, 2004, 10:37:12 by c h i l l a »

Offline D-J Valhala

  • Lord
  • ***
  • Posts: 294
  • Karma: +0/-0
(No subject)
« Reply #14 on: 16 January, 2004, 19:07:52 »
can you pls change it "<-RasTriv-> QUESTION - Nr. 18834 from 93913 Questions."

and add +hint
and +trivstart 1 (the trivia start with 1 Question)
+trivstart 20 (the trivia start with 20 Question)
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

Offline c h i l l a

  • Lord
  • ***
  • Posts: 347
  • Karma: +1/-0
(No subject)
« Reply #15 on: 16 January, 2004, 21:46:13 »
?(

I don't know why I should do it, when the script gets a question it gets a random questions, so latest the next questions, is random again.

And dunno if trivhint is worth it, I mean the script gives hints by itsself.

Guess you'll have to code it yourself.

Offline c h i l l a

  • Lord
  • ***
  • Posts: 347
  • Karma: +1/-0
(No subject)
« Reply #16 on: 17 January, 2004, 14:43:58 »
ahm...  done that triv hint thingy ;).

Offline c h i l l a

  • Lord
  • ***
  • Posts: 347
  • Karma: +1/-0
(No subject)
« Reply #17 on: 21 January, 2004, 16:59:41 »
some new stuff



   *** TRIVIA EX by CHILL ***

-- 21.1.04: V 0.63

1. Added possibility to Have own Questions Files. (sometimes slower and not randome)
   Files Must be like this:  Category$$Questions$$Answer, $$ can be changed in the LUA file (DivideChar)
   You also need to set :  HowToGetQuestions = 2  for own Questions Mode)
2. Added a nother way to display the Answers, Hints.

the LOOKS :)

+trivhelp
<-RasTriv-> -- Trivia Help --

   Prefixes:  + - !

   trivscore   - Show the top trivias.
   trivmyscore   - Shows your score.
   trivplayers   - Shows you the Trivia Players.
   trivskip   - Lets you skipp the current question.
   trivhint   - Gives you a hint.
   ------------------------
   login   - Lets you login.
   logout   - Logs you out.
   ------------------------
   trivstart  - Start the Trivia.
   trivstop   - Stop the Trivia.
   trivmain   - Plays Trivia in Main Chat.
   trivpm   - Plays Trivia in PM to the bot.
   triviaskip on/off  - Enables/Disables TriviaSkip.
   triviahint on/off  - Enables/Disables TrivHint.
   triviashowhint   - Switches between the 2 questions modes.
   ------------------------
   trivscorereset   - Lets you reset the score.
   ------------------------
   trivhelp   - Shows you this help.

Another Question File

Trivia Ex V.0.63

Offline kbeh273300

  • Double Ace
  • *
  • Posts: 106
  • Karma: +1/-0
    • The Ptokax LUA Language Board  Main Page
hello
« Reply #18 on: 22 January, 2004, 04:27:49 »
i just wanted to say VERY NICELY MADE BOT .


H??? ? K??g? hub owner and proud member of the Dream~Masters network
-=United Kings network=-
Network Webpage?
Hub address: houseofkings.no-ip.org:420
hub webpage
hub forum

Offline Event_Horizon

  • Lord
  • ***
  • Posts: 272
  • Karma: +3/-0
(No subject)
« Reply #19 on: 22 January, 2004, 11:40:25 »
THX CHILLA will check out the new one :D
Greez ????_H???z??
??????????????????

??/v\\ \'?\' ?@?? ???? is Secured by RoboCop? Created by Optimus?

Offline c h i l l a

  • Lord
  • ***
  • Posts: 347
  • Karma: +1/-0
(No subject)
« Reply #20 on: 22 January, 2004, 12:41:44 »
thanks :)

NICE to hear you like it.

Once again, I would appreciate it, if you guys could post links to question files. To make it bigger, and bigger. :).  Since it is built for huge question files.

Offline c h i l l a

  • Lord
  • ***
  • Posts: 347
  • Karma: +1/-0
(No subject)
« Reply #21 on: 23 January, 2004, 11:50:42 »
some fixes and memory released :))


-- 21.1.04 : V0.64

1. Switched to only have a question file, no seek file anymore. Less memory. Question get time is around 0.3 seconds. But runs now between 100 and 150 kb mem with over 80.000  questions. :)).
2. Some rewriting in how PM players are handled.
3. HowToGetQuestions changes now only between random and linear mode.
4. Added a few questions to the Trivia Rar. To show how it should look like.


Trivia Ex V0.64
« Last Edit: 23 January, 2004, 12:07:29 by c h i l l a »

Offline Event_Horizon

  • Lord
  • ***
  • Posts: 272
  • Karma: +3/-0
(No subject)
« Reply #22 on: 23 January, 2004, 14:36:14 »
nice runns smoth :D

maybe some more features soon ??
Greez ????_H???z??
??????????????????

??/v\\ \'?\' ?@?? ???? is Secured by RoboCop? Created by Optimus?

Offline c h i l l a

  • Lord
  • ***
  • Posts: 347
  • Karma: +1/-0
(No subject)
« Reply #23 on: 23 January, 2004, 14:52:08 »
i guess only..  a reload question func..

like +trivload file

file in the trivia folder...

but else

I already tahught about. Multiple answers, but then I have a problem with revealing the chars.
 so I'll leav it.

Maybe only some more player stats.
Any other ideas?

Offline lazyj189

  • Forum Ace
  • *****
  • Posts: 81
  • Karma: +1/-0
(No subject)
« Reply #24 on: 25 January, 2004, 05:40:47 »
noticing just a little problem with the trivia

example:
<-RasTriv-> QUESTION - Nr. 36096 from 93913 Questions.
   ----------------------------------------------------------------------
   > Category: Misc  -  Point(s):  2
   QUESTION: What Did Abebe Bikila Go Without In Winning The 1960 Oylmpic Marathon?
   HINT:  S@@@@
   ----------------------------------------------------------------------
<-RasTriv-> QUESTION - Nr. 36096 from 93913 Questions.
   ----------------------------------------------------------------------
   > Category: Misc  -  Point(s):  0
   QUESTION: What Did Abebe Bikila Go Without In Winning The 1960 Oylmpic Marathon?
   HINT:  Sho@@
   ----------------------------------------------------------------------
shoes
<-RasTriv-> Correct Misseymnm the answer was "Shoes", You get 0 Point(s).
<-RasTriv-> That gives you a total score of 2681 Point(s).


example2:
<-RasTriv-> QUESTION - Nr. 74550 from 93913 Questions.
   ----------------------------------------------------------------------
   > Category: Music : Album Title  -  Point(s):  4
   QUESTION: Dark Side Of The _____ (pink Floyd)
   HINT:  @@@@
   ----------------------------------------------------------------------
<-RasTriv-> QUESTION - Nr. 74550 from 93913 Questions.
   ----------------------------------------------------------------------
   > Category: Music : Album Title  -  Point(s):  2
   QUESTION: Dark Side Of The _____ (pink Floyd)
   HINT:  @@@@
   ----------------------------------------------------------------------
<-RasTriv-> QUESTION - Nr. 74550 from 93913 Questions.
   ----------------------------------------------------------------------
   > Category: Music : Album Title  -  Point(s):  0
   QUESTION: Dark Side Of The _____ (pink Floyd)
   HINT:  @@o@
   ----------------------------------------------------------------------
moon
<-RasTriv-> Correct Misseymnm the answer was "Moon", You get 0 Point(s).
<-RasTriv-> That gives you a total score of 2709 Point(s).

there was an example where if someone had answered the question correctly, it would ahve taken points away from their score.  any ideas?  I'm easy to get a hold of when not sleeping in.
DivX Dominion Hub Owner
3 years running
DivX Dominion Hub

PtokaX forum

(No subject)
« Reply #24 on: 25 January, 2004, 05:40:47 »