TriviaBot V.2.2 for Lua 5 - Page 2
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
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

TriviaBot V.2.2 for Lua 5

Started by Jelf, 15 March, 2005, 14:26:42

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dragos_sto

it possible but i think it a little to hard because u fave to
 synchronize answer whit question or to read from same line from both file.
So i thing it little easy to put them in one file

TommyGun

#26
Thanks for the answer.

But i got questions.txt with 7991 questions and answers.txt with 7991 answers. I got the tool EditPlus 2 but how can i make from this 2 txt's one txt?

Thanks in advance.
My computer specifications :: http://tweakers.net/gallery/sys/9478

Dessamator

the syntax for the file should be something like this:
QuoteFinish The Song Line: And she's buying a stairway _ _*to heaven

this is the question:
Finish The Song Line: And she's buying a stairway _ _


and this is the answer:
*to heaven



ps.: the answer always comes after the "*",

Good Luck !
Ignorance is Bliss.

Dessamator

#28
heres a script that should help, but theres 1 thing the lines must be exact in both cases.
eg: (file 1, line 1)what programming language are we using?
(file2,line1) lua !!!.

the script :

--By Dessamator
--Simple file(lines) "joiner"

file1 ="file1.txt" -- first file
file2 ="file2.txt" -- second file
file3 ="file3.txt" -- output file

function Main()
	local line1,temp,i="","",nil
	for line in io.lines(file1) do 
		if  i~= nil then
			temp=temp..line.." *"..line1.."\r\n" 	
		end
		for line2 in io.lines(file2) do 
			if i==nil then
				temp=temp..line.." *"..line2.."\r\n" 	
				i="1"
			else
				line1=line2
			end
		
		end
	end
	i=nil
	io.output(file3)
	io.output()
	local file = io.open(file3, "w+") -- "w" write
	file:write(temp)
	file:close()	
end
Ignorance is Bliss.

TommyGun

#29
Nevermind. I changed everything to one file :)
My computer specifications :: http://tweakers.net/gallery/sys/9478

lampje

what i'm doing wrong if i change some things..

i put now in trivia.dat this...

breinkraker: 97 - 90 =---------- *7
breinkraker: 31 - 30 =---------- *1
breinkraker: 99 - 90 =---------- *9
breinkraker: 27 - 20 =---------- *7
breinkraker: 13 - 10 =---------- *3
breinkraker: 44 - 40 =---------- *4

and more of this

but its not working X(

if i put the anwser in the main chat.. is nothing happend.
 ?(  ?(  ?(

no errors if i start the script

o syntax errors in script file Trivia.Lua5.lua
Script started.

what must i do to make it working?

TommyGun

Very strange. Your .Dat file is looking good...

But i got a questions;

What do i need to change so normal users can start the Trivia also?
My computer specifications :: http://tweakers.net/gallery/sys/9478

Stravides

Please can you help - I have made a couple of ammendments to this script to include the autoload at start - a skip function and changed the way the points work a little... problem is - since Lua 5.
If I run this for more than 10 mins it makes my PtokaX run at 100% cpu and kills the hub...

here is the code - can you test it with my question file too
CODE
Question File

Many thanks in Advance

Also in reply to make anyone start trivia try changing
   	elseif (string.lower(firstWord) == string.lower(StartTrigg)) then
      			if (curUser.bOperator) then
	        		if (lngWord == 0) then
          				playerArray[curUser.sName] = 1
          				SendToAll(BotName, strStart)
          				if (lngMode == 2) then
        	    				SendToPlayers(strStart)
	          			end
          				StopQuiz(1)
        			else
          				SendToAll(BotName, "There is already a game going on type "..JoinTrigg.." to join!")
        			end
	     		else
				curUser:SendPM(BotName, "Only Operators can start the Trivia because it might be off for a reason.")
      			end
to
   	elseif (string.lower(firstWord) == string.lower(StartTrigg)) then
        		if (lngWord == 0) then
       				playerArray[curUser.sName] = 1
       				SendToAll(BotName, strStart)
      				if (lngMode == 2) then
      	    				SendToPlayers(strStart)
         			end
       				StopQuiz(1)
      			else
       				SendToAll(BotName, "There is already a game going on type "..JoinTrigg.." to join!")
      			end
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

lampje

I dont know ..

meaby you can try this...

-- TriggStart is what char the commands should begin with I use ! but you can use # or whatever
TriggStart = "+"

now you can start the game with  +tbstart

but i dont know of a normal user can start the game with this command :)

Stravides

nothing to do with what character prefix you use....

its the line if (curUser.bOperator) then
that ask if current user is an operator then let them
see my previous post above !!!
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

TommyGun

#35
QuoteOriginally posted by Stravides
nothing to do with what character prefix you use....

its the line if (curUser.bOperator) then
that ask if current user is an operator then let them
see my previous post above !!!

It works perfect! Can you do the same with tbstop? Thanks!
My computer specifications :: http://tweakers.net/gallery/sys/9478

Stravides

well maybe ya coulda worked it out ....
change 1st to 2nd.....

   elseif (string.lower(firstWord) == string.lower(StopTrigg)) then
      if (curUser.bOperator) then
        HoldQuiz()
        StopQuiz()
        SendToAll(BotName, strStopp)
        if (lngMode == 2) then
          SendToPlayers(strStopp)
        end
      end
   elseif (string.lower(firstWord) == string.lower(StopTrigg)) then
        HoldQuiz()
        StopQuiz()
        SendToAll(BotName, strStopp)
        if (lngMode == 2) then
          SendToPlayers(strStopp)
        end
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

Stravides

Please can you help - I have made a couple of ammendments to this script to include the autoload at start - a skip function and changed the way the points work a little... problem is - since Lua 5.
If I run this for more than 10 mins it makes my PtokaX run at 100% cpu and kills the hub...

here is the code - can you test it with my question file too
CODE  
Question File  

Many thanks in Advance
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

kunal

can u add right click cmds for the trivia bot 2.2

Stravides

maybe something along these lines ... make sure the commands at the end match the triggers used in the main code

function Trivia(user)
	user:SendData("$UserCommand 255 7") 
	user:SendData("$UserCommand 0 3") 
	user:SendData("$UserCommand 1 3 *** "..frmHub:GetHubName().." Trivia ***$<%[mynick]>#124;") 
	user:SendData("$UserCommand 1 3 Admin\\Trivia\\Start Trivia$<%[mynick]> !trivia|") 
	user:SendData("$UserCommand 1 3 Admin\\Trivia\\Stop Trivia$<%[mynick]> !tbstop|") 
	user:SendData("$UserCommand 1 3 Trivia\\Join Trivia$<%[mynick]> !tbjoin|") 
	user:SendData("$UserCommand 1 3 Trivia\\Leave Trivia$<%[mynick]> !tbpart|") 
	user:SendData("$UserCommand 1 3 Admin\\Trivia\\Save Scores$<%[mynick]> !tbsave|") 
	user:SendData("$UserCommand 1 3 Trivia\\Show Players$<%[mynick]> !tbwho|") 
	user:SendData("$UserCommand 1 3 Trivia\\Show Top Ten$<%[mynick]> !topten|") 
	user:SendData("$UserCommand 1 3 Trivia\\Show Question$<%[mynick]> !tbquestion|") 
	user:SendData("$UserCommand 1 3 Trivia\\Hint Question$<%[mynick]> !hint|") 
	user:SendData("$UserCommand 1 3 Trivia\\Skip Question$<%[mynick]> !skip|") 
end



function NewUserConnected(user)
	Trivia(user)
end
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

Stravides

#40
Please can you help - I have made a couple of ammendments to this script to include the autoload at start - a skip function and changed the way the points work a little... problem is - since Lua 5.
If I run this for more than 10 mins it makes my PtokaX run at 100% cpu and kills the hub...

here is the code - CODE  
Question File  

I'm having so many problems running this script I am unsure where I can look for the fault - at least someone give me some ideas how to possibly trap the error :)

many thanks - Stravides
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

jiten

QuoteOriginally posted by Stravides
Please can you help - I have made a couple of ammendments to this script to include the autoload at start - a skip function and changed the way the points work a little... problem is - since Lua 5.
If I run this for more than 10 mins it makes my PtokaX run at 100% cpu and kills the hub...

here is the code - CODE  
Question File  

I'm having so many problems running this script I am unsure where I can look for the fault - at least someone give me some ideas how to possibly trap the error :)

many thanks - Stravides
Hi there m8.
Had a quick look, did some small changes and tested it for 15 minutes and seems to work OK now.
Wherever you find:
handle = io.open(file, "w")
replace it with
handle = io.open(file, "w+")
As you can see, an extra "+".
Guess that's the only problem.
Ah, another hint, you could use these for less repetition:
OpConnected = NewUserConnected
OpDisconnected = UserDisconnected
ToArrival = ChatArrival
Cheers m8

Stravides

#42
greatly appreciated - will test it now...

Well - sadly --- No hung the Ptokax Server process
at 99.99% ie nothing was processing - dont know why the cpu is being churned so much - any ideas ??
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

jiten

QuoteOriginally posted by Stravides
greatly appreciated - will test it now...

Well - sadly --- No hung the Ptokax Server process
at 99.99% ie nothing was processing - dont know why the cpu is being churned so much - any ideas ??

Tried running it again and it also hung up. So, my hints were wrong :(
Did you change something in the script?
Did this happen with the first Lua 5 version of the bot?

Stravides

very minor changes -
added a skip function and renamed some of the triggers.
changed the point values to reflect 4 hints ie 5,4,3,2,1 points

and changed the way the result is displayed to the user...

:)
apart from that no ;)  hehe
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

jiten

QuoteOriginally posted by Stravides
very minor changes -
added a skip function and renamed some of the triggers.
changed the point values to reflect 4 hints ie 5,4,3,2,1 points

and changed the way the result is displayed to the user...

:)
apart from that no ;)  hehe
Well, I left the first Lua 5 version by Jelf running till now (about 45 minutes) and it didn't crash, but, the memory usage is quite high (Mem: 2710 and GC: 4981) comparing to Trivia Ex. So, it can be something in the mods you made.

Stravides

Ok I have re-enabled the original and had it working solo on a test hub for nearly an hour
I place the exact code into the live hub and it kills the hub in minutes...

I am running my own smeagol bot also and believe that there must be an incompatability or its jsut down to the number of users on the server

I dunno...

but now tried :-
empty hub with just triv running     - OK
empty hub with triv & Smeagol running - OK
Full hub with just triv running - Crash
Full hub with triv & Smeagol running - Crash

so it must be the send to's that are killing the bandwidth surely ??? any ideas
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

?Tr??T_????

Can someone give me the trivia that works perfect???
save lad everything automatically...

Please....

sander815

how do i start this script?

it says ""tbstart  but nothing happens

i already changed TriggStart = "" to TriggStart = ! but then i get unexpected symbol near "!"

?Tr??T_????

in main type
tbstart

SMF spam blocked by CleanTalk