The following demo script almost works. That is to say that if you run demo.startfunc("att1"), the following is displayed in the main window:
Startfunc is calling function: att1
endfunc says hello and knows:
- a
- b
The point of fail is that rather than passing the arguments to demo.endfunc directly, I want to dynamically pass them from the contents of another variable - in this case demo.arglist
func(arglist) doesn't work, obviously. Is there a way?
demo = {}
demo.arglist = {"a", "b", "c"}
demo.funclist = {}
demo.startfunc = function( att )
echo("\nStartfunc is calling function: " .. att)
local func = demo.funclist[att]
local arglist = demo.arglist
func("a", "b")
end
demo.endfunc = function( ... )
echo("\n endfunc says hello and knows: \n")
local arglist = {...}
for _,a in ipairs(arglist) do
echo(" - " .. a .. "\n")
end
end
demo.funclist = {
att1 = demo.endfunc,
}
demo.startfunc("att1")