Get the lua command when a c function is called
Posted
by gamernb
on Stack Overflow
See other posts from Stack Overflow
or by gamernb
Published on 2010-05-25T18:02:31Z
Indexed on
2010/05/25
18:21 UTC
Read the original article
Hit count: 276
Supposed I register many different function names in Lua to the same function in C. Now, everytime my C function is called, is there a way to determine which function name was invoked?
for example:
int runCommand(lua_State *lua)
{
const char *name = // getFunctionName(lua) ? how would I do this part
for(int i = 0; i < functions.size; i++)
if(functions[i].name == name)
functions[i].Call()
}
int main()
{
...
lua_register(lua, "delay", runCommand);
lua_register(lua, "execute", runCommand);
lua_register(lua, "loadPlugin", runCommand);
lua_register(lua, "loadModule", runCommand);
lua_register(lua, "delay", runCommand);
}
So, how do I get the name of what ever function called it?
© Stack Overflow or respective owner