I'm new to lua and want to store a function in a table with parameters given at "store time".
Tried this code but does not what I want (obviously).
local functable = {}
local function myfunc(x,y)
print(x ,y)
end
table.insert(functable, {func = myfunc})
table.remove(functable).func("hello", "World")
I would like to store the variables at "insert" so I tried to store the parameters in the table:
functable = {}
function myfunc()
print(functable[#functable].p1 ,functable[#functable].p2)
end
table.insert(functable, {func = myfunc, p1="Hello", p2="World"})
table.remove(functable).func()
but this code does not work.
Can someone point me to the right direction?