I have some functions declared and initialized in .lua file. Then, when I receive signal, I read string_t variable with the name of function to call from file. The problem is that I don't know how to push function to stack by its name or call it.
For example:
test.lua
function iLoveVodka()
--some text
end
function iLoveFish()
--another text
end
C File:
string_t a = "iLoveVodka()"
How can i call function from C/C++ code iLoveVodka() only by having its name?
lua_pcalllua_getglobal(state, "iLoveVodka");, or alternatively push its name on the stack and calllua_getfield. (Don't be afraid to explore around lua.org/manual/5.1/#index )iLoveVodka()) as opposed to just the name of the function you can useluaL_dostringor the functions it is a macro around to run that chunk of code.