Slot Bot Help
 

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

Slot Bot Help

Started by nEgativE, 17 March, 2005, 12:13:25

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nEgativE

Hi, could someone help with this slots script.. i get some syntax errors like

Slots.lua:5: unexpected symbol near `%'
SlotBot

-- Adaptation by OpiumVolage (01 July 2003) based on 
-- retrobot? v0.99? 
-- slots module 
-- by tezlo 
-- 2003 
--
botName = "[operserv]" 
--
function getid(table, name) 
return table.foreachi(table, function(id, item) if item.sName == %name then return id end end) 
end 
--
function putitem(table, item) 
if not item then return end 
local id = getid(table, item.sName) 
if id then table[id] = item 
else table.insert(table, item) id = table.n 
end return id 
end 
--
function OnTimer() 
local i = 1 while tabSlots[i] do 
local table = tabSlots[i] 
if os.clock() >= table.iClock + tmrSlots then 
if table.tItems.n == 0 then 
SendPmToNick(table.sName, botName, "DC:CLP - N?o foram encontrados usu?rios com slots livres.|")
end 
SendPmToNick(table.sName, botName, "DC:CLP - Verifica??o completa.|") 
tos.remove(tabSlots, i) 
if tabSlots.n == 0 then frmHub:EnableSearchData(0) end 
else i = i + 1 end 
end 
end 
--
function slotsOnHub(user, args) 
local s, e, free, all = string.find(args, " (%d+)/(%d+)"..string.char(5)) 
table.foreachi(tabSlots, function(id, item) 
if not getid(item.tItems, %user.sName) then 
putitem(item.tItems, { sName = %user.sName, sValue = %free.."/"..%all }) 
-- if item.sTarget and (%user.sName == item.sTarget) then 
-- SendPM(item.sName, " Usu?rio "..%user.sName.." "..%free.."/"..%all.."|") 
-- item.iClock = item.iClock - tmrSlots 
-- elseif not item.sTarget and 
if (tonumber(%free) >= item.iNR) then 
SendPmToNick(item.sName, botName, "Usu?rio(a): "..%user.sName.." - Dispon?veis: "..%free.." - Total: "..%all.."|") 
end 
end end) 
end 
--
function doSlots(user, nr, nick) 
SendToAll(botName, "DC:CLP - A efetuar verifica??o de slots dispon?veis no Hub, a pedido de um usu?rio(a) - [comando: !slots]")
SendToOps(botName,"OP MSG - A efetuar verifica??o de slots dispon?veis no Hub, por: "..user.sName..".")
user:SendPM(botName, ""..user.sName..", a verifica??o n?o pode ser efetuada a usu?rios em Modo Passivo.|") 
user:SendPM(botName, "DC:CLP - Aguarde, verificando..|") 
frmHub:EnableSearchData(1) 
SendToAll("$Search Hub:"..Command.." T?F?0?1?.|") 
putitem(tabSlots, { sName = user.sName, iClock = os.clock(), iNR = nr, tItems = {n=0} }) 
end 
--
tmrSlots = 5 -- Number of seconds waiting for replys 
tabSlots = {n=0} 
Command = "!slots" 
--
function ChatArrival(user, data) 
if string.find(data, "%b<>%s+("..Command..").*|") then 
s, e, nr = string.find(data, "%b<>%s+"..Command.."%s+([0-9]+)") 
if s then nr = tonumber(nr) else nr = 1 end 
doSlots(user, nr) return 1 
end 
if string.find(data, "^%$SR") then slotsOnHub(user, data) end 
end 
--
function Main() 
SetTimer(tmrSlots*1000) 
StartTimer() 
end
--

bastya_elvtars

Remove % from before variable names, so

"..%user.sName.."
will be
"..user.sName.."

%var format upvalues are deprecated in lua5.
Everything could have been anything else and it would have just as much meaning.

nEgativE

Tks bastya_elvtars, i will do that :)

bolamix

Oooh I was so hopeful... I've been trying to convert this script since PtokaX went to lua5, and I was like "someone's made it! yippee!"
But I get the same error I had with my attempts: "Syntax error in ..\PtokaX_0.3.3.0.b16.06.nt.dgb\scripts\SlotsBot_Lua5.lua:20: attempt to call field `foreachi' (a nil value)"

Bwaaahahahaaa  ;(
Sharing is of the essence!

Live music >> Aiwadirock! live music hub
PtokaX knowledge >> The PtokaX Wiki

bastya_elvtars

table.concat does not work either
Everything could have been anything else and it would have just as much meaning.

jiten

Check this  thread.

Best regards.

SMF spam blocked by CleanTalk