In my lua script, I need to call a function that takes a conditional number of arguments with, well, an arbitrary number of arguments ...
I create my arguments as a table, because I can not know how many arguments will be.
Code example:
local result = call.someFunc();
local arguments = {}
for k,v in pairs(result) do
table.insert(arguments, v.name)
end
-- here I would like to somehow pass the whole table and each item in the table
-- is then passed as a single argument to "someOtherFunc"
call.someOtherFunc(arguments[1], arguments[2], arguments[3] ....)
I am new to lua, in PHP e. d. I would use call_user_func_array - is there something similar in lua?
source
share