I used the Phrase-O-Rama Lua 5.0 version by mutor and used the 50to51.exe file to make the 5.1 Lua file.
No errors were given using this conversion.
But when running the script in latest ptokax, with robocop 1.0.22, I get the following error:
PoR_1.0b_L5.1.lua:335: bad argument #2 to 'random' (interval is empty)
no idea what is causing this.....
Quote
PoR_1.0b_L5.1.lua:335: bad argument #2 to 'random' (interval is empty)
no idea what is causing this.....
That doesnt give much info to work with :-\
can you paste the function including line 335 in here please or maybe even the whole script ?
-- Phrase-O-Rama Script 1.0b LUA 5
-- By Chaggydawg
-- Version 0.3b
--
-- Much like a trivia script, be first to answer the hidden phrase
-- before it is revealed. Unlike most trivia script, this one does
-- does NOT bogg the hub down, nor does it consume more than 1Mb of
-- memory. You can add your own phrase lists as text files
-- This is a fantastic script and my hubbers play it often
--
-- Modded by Mutor 9-22-04
-- Changes:
--
-- + Added Display of available phrase lists
-- + Added option for right click menu
-- + Loads/saves active list to file when hub/scripts restart
-- + Added option to enable/disable specified list
-- + Shortened the timer to make it a bit more fun
-- + Added a few more phrase lists
-- + Added delay for phrase reveal
--
-- +Converted to LUA 5 2/23/05 by Mutor
-- +Converted to LUA 5.1 on 17/07/06 by Propaganda
--
--User Settings-------------------------------------------------------------------------------------
timer = 5000 --Initial delay in ms from script start to game start
phrasetimer = "m" --Delay for phrase reveal. s/m/f = slow/medium/fast
BotName = "U2 Trivia Game" -- Bot name pulled from the hub
phrasefile = "phraselists.txt"
SendCmdMenu = "yes" --Send context menu? (right click menu) "yes"/"no"
MenuName = "U2 Trivia Game"
gameon = "off" --Game on at hub/script restart? "off"/"on"
--End User Settings----------------------------------------------------------------------------------
--
phrases = {}
phraselists = {}
topscores = {}
answer = ""
remainscore = 0
phrasenumbers = {}
startingphrase = 1
function Main()
if loadfile(phrasefile) then
dofile(phrasefile)
else
SendToOps(phrasefile.." not found. Be sure to place it in your /scripts folder.")
end
SetTimer(timer)
doreadscores()
doreadphrases()
donewphrase()
if gameon == "on" then StartTimer() end
end
function NewUserConnected(user,data)
if SendCmdMenu == "yes" then
user:SendData(sBotName, "U2 Trivia Game menu enabled, right click hub tab for commands.")
UserCmds(user)
if user.bOperator then
OpCmds(user)
end
end
end
OpConnected = NewUserConnected
function UserCmds(user)
user:SendData("$UserCommand 1 3 "..MenuName.."\\[PoR]\\POR Show Lists$<%[mynick]> +porlist||")
user:SendData("$UserCommand 1 3 "..MenuName.."\\[PoR]\\POR Top 10 Scores$<%[mynick]> +scores||")
user:SendData("$UserCommand 1 3 "..MenuName.."\\[PoR]\\POR Your Score$<%[mynick]> +myscore||")
user:SendData("$UserCommand 1 3 "..MenuName.."\\[PoR]\\POR Help$<%[mynick]> +porhelp||")
end
function OpCmds(user)
user:SendData("$UserCommand 1 3 "..MenuName.."\\[PoR]\\POR On$<%[mynick]> +startgame||")
user:SendData("$UserCommand 1 3 "..MenuName.."\\[PoR]\\POR Off$<%[mynick]> +stopgame||")
user:SendData("$UserCommand 1 3 "..MenuName.."\\[PoR]\\POR Toggle Lists$<%[mynick]> +toggle %[line:List-Name]||")
user:SendData("$UserCommand 1 3 "..MenuName.."\\[PoR]\\POR Phrase Delay$<%[mynick]> +ptimer %[line:Delay:s/m/f=slow/medium/fast]||")
user:SendData("$UserCommand 1 3 "..MenuName.."\\[PoR]\\POR Skip Phrase$<%[mynick]> +skip||")
end
function OnExit()
SaveToFile(phrasefile , phraselists , "phraselists")
end
function ChatArrival(curUser, Data)
s,e,cmd = string.find(Data,"%b<>%s(%S+)")
s,e,cmd2,list = string.find(Data,"%b<>%s+(%S+)%s(.+)|")
s,e,cmd3,delay = string.find(Data,"%b<>%s+(%S+)%s(%a)|")
s,e,scored = string.find(Data,"%b<>%s%S+%s+(%d+)")
s,e,mess = string.find(Data, "%b<>%s+(.*)")
if cmd == "+startgame|" then
dostartgame(curUser)
return 1
elseif cmd == "+stopgame|" then
dostopgame(curUser)
return 1
elseif cmd == "+scores|" then
displayscores(curUser)
return 1
elseif cmd == "+porhelp|" then
dohelp(curUser)
return 1
elseif cmd == "+porlist|" then
dolists(curUser)
return 1
elseif cmd =="+skip|" then
doskipphrase(curUser)
return 1
elseif cmd == "+myscore|" then
domyscore(curUser)
return 1
elseif cmd2 == "+toggle" then
editlists(curUser)
return 1
elseif cmd3 == "+ptimer" then
phrasetime(curUser)
return 1
end
if mess ~= nil and answer ~= " " then
mess = string.gsub(mess,"%A","")
ants = string.gsub(answer,"%A","")
if string.find(string.lower(mess),string.lower(ants)) ~= nil then
addtoscore(curUser,remainscore)
answer, startingphrase = donewphrase()
return 1
end
end
end
function phrasetime(curUser,Data)
if not delay then
curUser:SendData("Syntax "..cmd3.." <s/m/f> (s=slow m=medium f=fast.)")
else
curUser:SendData("Phrase delay set to: ["..delay.."] - ( Where: s=slow m=medium f=fast )")
phrasetimer = delay
end
end
function dolists(curUser)
local plist = ""
local status = ""
local which = ""
for i, v in pairs(phraselists) do
which = i
if v == "on" then
status = " Active"
else
status = "Inactive"
end
plist = plist.."\t"..status.." - "..which.."\r\n"
end
local dsp
dsp = "\r\n\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
dsp = dsp.."\t=-=-= Available U2 Trivia Game Phrase Lists =-=-=\r\n"
dsp = dsp.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
dsp = dsp..plist
dsp = dsp.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
dsp = dsp.."\t=-= Enable/Disable Lists: +toggle <listname> =-=\r\n"
dsp = dsp.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
curUser:SendData(dsp)
plist = ""
status = ""
which = ""
dsp = ""
end
function editlists(curUser,Data)
if not phraselists[list] then
curUser:SendData("Syntax "..cmd2.." <listname> Type +porlist for available phrase lists.")
elseif phraselists[list] == "on" then
phraselists[list] = "off"
curUser:SendData(list.." - Disabled")
elseif phraselists[list] == "off" then
phraselists[list] = "on"
curUser:SendData(list.." - Enabled")
end
SaveToFile(phrasefile , phraselists , "phraselists")
end
function OnTimer()
doreveal()
end
function donewphrase()
doreadphrases()
answer = phrases[math.random(1,table.maxn(phrases))]
startingphrase = 1
remainscore = math.random(1,3)
e,f = string.gsub(answer,"%a","")
if phrasetimer == "s" then --slow
timer = 200 / f * 1000 --Longer delay
elseif phrasetimer == "m" then --medium
timer = 200 / f * 500 --Medium delay
elseif phrasetimer == "f" then --fast
timer = 200 / f * 300 -- Shorter delay
end
SetTimer(timer)
return answer,startingphrase
end
function doreveal()
if startingphrase == 1 then testing = string.gsub(answer,"%a","•"); startingphrase = 0; SendToAll(BotName,"This Phrase will be worth "..remainscore.." point(s) per unrevealed letter plus 5 points for solution."); end
t,p = string.gsub(testing,"•","")
if p < 2 then
SendToAll(BotName,"The Answer Was: "..answer)
donewphrase()
else
curnumber = burp()
testing = string.sub(testing,1,curnumber-1)..string.sub(answer,curnumber,curnumber)..string.sub(testing,curnumber+1,string.len(testing))
SendToAll(BotName,"[Category: "..phrasename.."] "..testing)
end
end
function burp()
curnumber = math.random(1,string.len(answer))
if string.sub(testing,curnumber,curnumber) ~= "•" then burp() end
return curnumber
end
function dostartgame(curUser)
if gameon == "off" then
gameon = "on"
donewphrase()
StartTimer()
SendToAll(BotName, curUser.sName.." Has Started a the U2 Trivia Game!")
end
end
function dostopgame(curUser)
if gameon == "on" then
gameon = "off"
SendToAll(BotName, curUser.sName.." Has Ended the U2 Trivia Game ")
SendToAll(BotName,"The Answer Was: "..answer)
StopTimer()
answer = " "
remainscore = 0
dowritescores()
end
end
function displayscores(curUser)
tscores = ""
table.sort(topscores, function(a,b) return a[1]>b[1] end)
total = 10
if table.maxn(topscores) < total then total = table.maxn(topscores) end
for i = 1,total,1 do
tscores = tscores.."\t["..i.."] "..topscores[i][2].." - "..topscores[i][1].."\r\n"
end
local dsp
dsp = "\r\n\r\n\t=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=\r\n"
dsp = dsp.."\t=-=-= Top 10 U2 Trivia Game Players =-=-=\r\n"
dsp = dsp.."\t=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=\r\n"
dsp = dsp..tscores
dsp = dsp.."\t=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=\r\n\r\n"
curUser:SendData(dsp)
tscores = ""
dsp = ""
end
function addtoscore(curUser,remainscore)
dude = table.maxn(topscores)+1
oldscore = 0
for i = 1,table.maxn(topscores),1 do
if topscores[i][2] == curUser.sName then
dude = i
oldscore = topscores[i][1]
break
end
end
a,b = string.gsub(testing,"•",".")
topscores[dude] = {(b*remainscore)+oldscore+5,curUser.sName}
dowritescores()
table.sort(topscores, function(a,b) return a[1]>b[1] end)
for i = 1,table.maxn(topscores),1 do
if topscores[i][2] == curUser.sName then
SendToAll(BotName,curUser.sName.." Got It!! The Answer Was: "..answer)
SendToAll(BotName,curUser.sName.." has been awarded "..((b*remainscore)+5).." points!")
SendToAll(BotName,"["..i.."] "..topscores[i][2].." - "..topscores[i][1])
end
end
end
function dowritescores()
local f,e = io.open("por/porscores.txt", "w" )
if f then
f:write("1&"..topscores[1][2].."$"..topscores[1][1])
f:close()
local f,e = io.open("por/porscores.txt", "a" )
for i = 2,table.maxn(topscores),1 do
f:write("\n"..(i).."&"..topscores[i][2].."$"..topscores[i][1])
end
f:close()
return 1
else
return nil,"Write Scores failed: "..e
end
end
function doreadscores()
local f,e = io.open("por/porscores.txt","r")
if f then
A=1
while 1 do
local line = f:read( "*l" )
if line == nil then break end
s,e,rank,unick,score = string.find(line,"(%S+)&(%S+)$(%S+)")
topscores[tonumber(A)] = {tonumber(score),unick}
A = A+1
end
A = nil
f:close()
else
return nil,"loadfile failed: "..e
end
end
function doreadphrases()
phrases = {}
tempTable = {}
for i,v in pairs(phraselists) do
if v == "on" then table.insert(tempTable,i) end
end
phrasename = tempTable[math.random(1,table.maxn(tempTable))]
local f,e = io.open("por/"..string.lower(phrasename)..".txt","r")
if f then
t=1
while 1 do
local line = f:read( "*l" )
if line == nil then break end
phrases[t] = line
t = t+1
end
f:close()
else
return nil,"loadfile failed: "..e
end
end
function dohelp(curUser)
SendToAll("...")
local tmp
tmp = "\r\n\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=<>=-=\r\n"
tmp = tmp.."\t\tU2 Trivia Game User Command Help\r\n"
tmp = tmp.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=<>=-=\r\n"
tmp = tmp.."\t+porlist : Displays Active Phrase Lists\r\n"
tmp = tmp.."\t+scores : Displays Top 10 U2 Trivia Game Scores\r\n"
tmp = tmp.."\t+myscore : Displays your U2 Trivia Game Score\r\n"
tmp = tmp.."\t+porhelp : Displays U2 Trivia Game Help\r\n"
if curUser.bOperator then
tmp = tmp.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=<>=-=\r\n"
tmp = tmp.."\t\tU2 Trivia Game OP Command Help\r\n"
tmp = tmp.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=<>=-=\r\n"
tmp = tmp.."\t+startgame : Begins U2 Trivia Game Game\r\n"
tmp = tmp.."\t+stopgame : Stops U2 Trivia Game Game\r\n"
tmp = tmp.."\t+skip : Skips the Current Phrase\r\n"
tmp = tmp.."\t+toggle <listname> : Enable/Diable Lists\r\n"
end
tmp = tmp.."\t---<>------------------------------------------------------------------<>---\r\n"
--if curUser.bOperator then
curUser:SendData(tmp)
end
function domyscore(curUser)
table.sort(topscores, function(a,b) return a[1]>b[1] end)
for i = 1,table.maxn(topscores),1 do
if topscores[i][2] == curUser.sName then
curUser:SendData(BotName,"Rank ["..i.."] "..topscores[i][2].." - "..topscores[i][1])
break
end
end
end
function doskipphrase(curUser)
if curUser.bOperator then
SendToAll(BotName,curUser.sName.." has Skipped this phrase.")
SendToAll(BotName,"No Points Awarded This Round.")
SendToAll(BotName,"The Answer was: "..answer)
donewphrase()
end
end
function Serialize(tTable, sTableName, sTab)
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.."={"
local tStart = 0
for key, value in pairs(tTable) do
if tStart == 1 then
sTmp = sTmp..",\r\n"
else
sTmp = sTmp.."\r\n"
tStart = 1
end
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..SerializeCrazy(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
end
sTmp = sTmp.."\r\n"..sTab.."}"
return sTmp
end
function SaveToFile(file , table , tablename)
local f,e = io.open( file, "w+" )
if f then
f:write(Serialize(table, tablename))
f:close()
return 1
else
return nil,"SaveToFile failed: "..e
end
end
Can you please attach next time? :P
Quote from: bastya_elvtars on 29 July, 2006, 23:31:16
Can you please attach next time? :P
Sorry....yes I will...
Quote from: Mutor on 30 July, 2006, 01:16:32
More than likley it was a problem with your phrasefile.
Attached find the script, phrasefile.txt and some phraselists
Running here on Px 0.3.5.1 LUA 5.11
Thanks Mutor for helping me (us) out on this......will let you know how this works for us....
well i used this script and was gettin the following error
Syntax [string "-- Phrase-O-Rama Script 1.0b LUA 5.0/5.1..."]:31: attempt to perform arithmetic on global 'Phrase' (a nil value)