Calling lua function which name is stored in string

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Calling lua function which name is stored in string

darqan
Hello,

Is it possible (in plain LUA) to call a (LUA) function which name is stored in string (like reflection)?

What I want to do is something like:

function foo( object )
   func = string.format("script_%s", object:getValue() )
   -- somehow call function which name is stored in variable 'func'  (e.g. script_shoot )
end

Of course this is easy to do so that I generate the string in c++ and call LUA function from there but I really would like to do this whole thing in LUA if it is possible.

Thank you.