What I really want is self-modifying code in Lua, but since Apple doesn’t allow it (i.e. Lua’s DoString() function), and Corona doesn’t support it, is there any way I can load variables dynamically?
The require function does this only at start-up.
Here is what I’d like to do is something like this fictitious setVariable function which would be referenced as follows:
myVariables={“id”,“firstName”, “lastName”}
myValues={44,“Bob”, “Gordon”}
local a
for a=1, #myVariables do
setVariable(myVariables[a],myValues[a])
end
Ideally, this code would effectively set id=44, firstName=“Bob” and lastName=“Gordon”
Any ideas? Is there a Lua function that Corona supports that would allow me to do this?
To be specific about my practical need, I am losing my textures on Android on ApplicationSuspend or ApplicationExit. Therefore, on ApplicationResume, I want to be able to load them up from a table, including their X and Y positions, too. Without the ability to setVariable as described above, I would need to write laborious code specific to every texture and location.