Let's say I've got callback function which is executed when specified player dies.
function OnPlayerDeath(playerid)
end
I want this function to be called inside Lua C module without putting it inside lua script:
static int l_OnPlayerConnect (lua_State * L) {
enum { lc_nformalargs = 1 };
lua_settop(L,1);
// so here I can use playerid argument - 1 arg
return 0;
}
It is somehow possible to receive this callback argument in C?
#define LUA extern "C" __declspec(dllexport) int __cdecl
LUA luaopen_mymodule(lua_State *L)
{
/* function OnPlayerConnect( playerid )
*
* end */
lua_pushcfunction(L,l_OnPlayerConnect);
lua_setfield(L,LUA_GLOBALSINDEX,"OnPlayerConnect"); //there's already OnPlayerConnect I just want to also call it here but I don't know how.
assert(lua_gettop(L) - lc_nextra == 0);
return 1;
}
I don't want to push this function onto the lua stack because this func already exists. I just want it to be already existing Lua function.