PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: Alexandros on 26 February, 2005, 06:40:07

Title: error converting to LUA5
Post by: Alexandros on 26 February, 2005, 06:40:07
how do you convert this line:
return foreachi(table, function(id, item) if item.sName == %name then return id end end)
of this script http://www.plop.nl/ptokaxbots/OpiumVolage/freeslotbot1.lua to lua5...it seems have a error in %name.

thanks
Title:
Post by: Optimus on 26 February, 2005, 11:31:17
Thats no longer possible... some 1 correct me if i'm wrong
Title:
Post by: Tw?sT?d-d?v on 26 February, 2005, 12:04:18
hi , i got prob with converting script .... i get the error..

scripts\trivia.lua:694: attempt to call global `openfile' (a nil value)

help plz
Title:
Post by: Optimus on 26 February, 2005, 12:09:32
patience is needed m8, things are not going that fast. though some 1 could help ya :D
Title:
Post by: Tw?sT?d-d?v on 26 February, 2005, 12:13:41
LOL ... ok m8   thx
Title:
Post by: plop on 26 February, 2005, 15:21:29
foreach shouldn't ever be used as it's slower then a normal table loop.
the upvallue's used (%name) are removed from lua 5, you need 2 rewrite it fully.
a function inside the function works if you return the locals from the nested function.

lua 5 only handles files by using file handles.
so again here you gotta rewrite the part.
fFile = io.open(filename)
or the new cool way 2 proces every line in a file.
for line in io.lines(filename) do

these things all should be manualy converted as the code differs a bit 2 much on lua 5 (the resulting code is about half the size).

plop
Title:
Post by: ??????Hawk?????? on 26 February, 2005, 16:57:53
QuoteOriginally posted by Alexandros
how do you convert this line:
return foreachi(table, function(id, item) if item.sName == %name then return id end end)
of this script http://www.plop.nl/ptokaxbots/OpiumVolage/freeslotbot1.lua to lua5...it seems have a error in %name.

thanks


Try just removing the   %  see  what happens  ..  

worked ok for me in my script   :))  :))  :))


??????Hawk??????
Title:
Post by: Tw?sT?d-d?v on 26 February, 2005, 17:43:35
hmm ..... still need help .... can some1 help me to convert triv game plz ... it's to big to post here .... ill need to send it some1 if they are able to help
Title:
Post by: Alexandros on 26 February, 2005, 17:45:47
thanks to all :)
Title:
Post by: ??????Hawk?????? on 26 February, 2005, 17:51:45
QuoteOriginally posted by (uk)jay
hmm ..... still need help .... can some1 help me to convert triv game plz ... it's to big to post here .... ill need to send it some1 if they are able to help

im sure the creater of your triv bot is doing overtime now  converting it  ...

for now you could use XN with  security disabled for games only  ..

triv , anagrams , war games , HangMan


??????Hawk??????
Title:
Post by: bastya_elvtars on 01 March, 2005, 11:31:36
Quoteplop wrote:

or the new cool way 2 proces every line in a file.
for line in io.lines(filename) do

This rocked my world, really nice 1.  :D

-- // edit

my 1024th post, at last a round number!
Title:
Post by: Herodes on 02 March, 2005, 14:38:43
QuoteOriginally posted by bastya_elvtars
my 1024th post, at last a round number!
Hehehe,... you geek ..  :D