trivia ex
 

News:

11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

trivia ex

Started by c h i l l a, 07 January, 2004, 15:13:55

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

c h i l l a

my first trivia release.
still very small but lost to come I hope.

--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?

c h i l l a

lets see how long this one holds :)

my first trivia bot

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

plop

QuoteOriginally 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 <----<<

*??G??*

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

c h i l l a

#4
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/

*??G??*

hmmmm......so i guess there is no way to put this on a timer then.

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

lazyj189

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

c h i l l a

thanks lazyj189 ;),

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

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

and you need to edit the Max7.

D-J Valhala

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]=--
==================

c h i l l a

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.

Event_Horizon

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?

*??G??*

Thanks Chilla.......keep up the good work.

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

Event_Horizon

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?

c h i l l a

#13
sometimes I don't post, updates here, so you need to check the site for yourself.

enjoy :)


Trivia EX

D-J Valhala

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]=--
==================

c h i l l a

?(

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.

c h i l l a

ahm...  done that triv hint thingy ;).

c h i l l a

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

kbeh273300

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

Event_Horizon

THX CHILLA will check out the new one :D
Greez ????_H???z??
??????????????????

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

c h i l l a

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.

c h i l l a

#21
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

Event_Horizon

nice runns smoth :D

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

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

c h i l l a

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?

lazyj189

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

SMF spam blocked by CleanTalk