In my Lua code (using the Corona SDK), my issue essentially boils down to this:
local function foo()
bar()
end
local function bar()
foo()
end
However, because Lua is done line-by-line, this has no chance of working. Futhermore, I don’t see a way to avoid this dependency loop; foo() creates DisplayObjects that call bar() for touch events, which itself has the capability of calling foo(). To put it another way, I need to be able to make buttons that, when clicked, make more buttons that can do the same thing.
Futhermore, I know Lua doesn’t have function prototyping like in C/C++. Any suggestions for how to fix this?
Remember that
is syntactically equivalent to:
So it’s a simple matter of declaring the local variables, but setting their function values after the declaration: