How can you call a function name via a string in Lua on self
?
I tried the techniques described on the similar question (lua call function from a string with function name), however this only addresses calling functions that exist on the global table, or through modules; it does not work on self
.
Here is a simplified example of what I'm trying to do.
function CardsScene:onEnterFrame()
if self.transition_complete then
loadstring("self.basicMathInit")()
end
end
function CardsScene:basicMathInit()
print("Init has been called.")
end
This results in the following error.
scenes/CardsScene.lua:83: attempt to call a nil value