PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: Jerry on 11 June, 2005, 23:11:37

Title: Convert LUA4 -> LUA5
Post by: Jerry on 11 June, 2005, 23:11:37
Hi ppl,

Can you somebody help me with this script, I need convert from LUA4 to LUA5!:

I convert script into LUA5 with NighLitch's convertor with GUI,
but PX report this: [23:05] Syntax wmBot/main.lua:97: unexpected symbol near `.'at this time :(

The error is in this line: local min, math.max = string.byte("A"), string.byte("Z")
Can you help me with convert, please?

 THX
Title:
Post by: ??????Hawk?????? on 11 June, 2005, 23:20:00
hi m8  


post the script in full  ..
Title:
Post by: jiten on 11 June, 2005, 23:21:30
Try replacing "math.max" with only "max".

Best regards,

jiten
Title:
Post by: Jerry on 11 June, 2005, 23:23:25
OH, THX jiten it's working at this time!

But I have next problem, here is the script:
botname = config.botname

aboutinfo = "wmBot 0.22-1 JAFRA edit"

ownerlevel = 100

possrights = {
hubadmath.min = 1,
opadmath.min = 1
}

ops = {
indexof = function(name)
for i = 1, table.getn(ops.items) do
if string.lower(name) == string.lower(ops.items[i].name) then
return i
end
end
end,
items = { }
}

capslockwarns = { }
And the PX report this:[23:25] Syntax wmBot/defs.lua:8: `}' expected (to close `{' at line 7) near `='Where is the problem?
Title:
Post by: jiten on 11 June, 2005, 23:46:39
Replace this part of it:
possrights = {
hubadmin = 1,
opadmin = 1
}
Cheers
Title:
Post by: Jerry on 12 June, 2005, 00:00:32
Hi jiten,

Thank you very much, it's working OK at now!

But I have only one, final problem:
in this script:
-- vtipy jsou nacitany ze souboru vtipy.txt ve stejnem adresari jako tento soubor
-- jednotlive vtipy oddelte znakem ~ (vlnovka) na samostatnem radku

-- napr:

-- vtip1
-- .....
-- ~
-- vtip2
-- .....
-- ~
-- vtip3
-- ....

commands["vtip"] = function(user, arg)
f = openfile("wmBot/modules/vtipy/vtipy.txt", "r")
if f then
count = 1
line = read(f)
while line do
if strsub(line, 1, 1) == "~" then
count = count + 1
end
line = read(f)
end
index = random(1, count)
seek(f, "set", 0)
i = 1
cur = ""
line = read(f)
while line do
if strsub(line, 1, 1) == "~" then
if i == index then
break
end
i = i + 1
cur = ""
else
cur = "\013\010"..cur..line
end
line = read(f)
end
closefile(f)
chat(cur)
end
end

modulehelp = modulehelp..
"\013\010.vtip - rekne vtip"

Th PX report:[23:57] Syntax module.lua:46: attempt to index global `commands' (a nil value)
Can you PLS help me with this latest problem with this script -> THX!!!
Title:
Post by: jiten on 12 June, 2005, 12:51:47
Add this before "commands["vtip"] = function(user, arg)":
commands = {}
Cheers
Title: HELP script 4 ptocax 0.3.3.0 build 17.09
Post by: boomalek on 12 June, 2005, 14:49:51
hi, i'm Massimo,
i'd like to know how can i compare 2 strings and find a substring in a string.
when i used the verion 15.09 of ptokax i used this commands

(strsub(strlower(data),1,3)==strlower("$SR"))

and


_,_,fileString = strfind(data,"$SR%s+%S+%s+(.+).*")

but don't work in this ptokax's version.
How can i do it?
tnx 4 attention  answer me if u can bye
Title: continue..
Post by: boomalek on 12 June, 2005, 14:58:55
ptokax report this error..

[14:32] Syntax ...o procazzo\scripts\Segnala i file proibiti_v1.1z.lua:224: attempt to call global `strsub' (a nil value)