Lua: Get all functions defined in script
Hey,
I've been programming with Lua for several weeks and now I've started creating a
script module for my game engine.
But now I've got a problem. I want to know all the functions that are
defined in the script, e.g
function Func1()
-- lala
end
function Func2()
-- lala
end
and the engine should then display the names of Func1 and Func2 after execution.
Well, displaying is not usefull, but it in the editor it will.
I think the solution is pushing all global variables on the stack, but how?
I know that you can push one with lua_getglobal(), but only if you know its name :P
Could anybody help me?
Regards,
Perceptron
The table _G (that's underscore, capital G) contains all global functions and variables. You can iterate through that table (see lua_next), and use lua_gettype to check if a value is a function.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement