args in funcs in tables

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
the underminer
Posts: 123
Joined: Mon Oct 03, 2005 4:25 am
Location: Netherlands

args in funcs in tables

Post by the underminer »

I'm using this construction a lot:

Code: Select all

function test()
--code
end

funcs = {test}

funcs[1]()
to call a function from a table. But how can I send arguments along?
The args should be between the () but because there are no () in {test}, I don't know how to do this. It would be very useful, because I use variables know instead of args to control function behaviour with this construction.

thnx for the help
Behold! The Underminer got hold of a PSP
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

umm here this might help.

varlist = {
funct()
do stuff here... etc

end,

funct()

more stuff here

end,

etc..

}

varlist[1]() 2 3 etc.. can be called using this

You can also define functions as variables.

functionX = funct(foo)
do stuff here

end
Post Reply