lua_CFunction requires that a function follows the structure:
int FunctonName(lua_State* L);
You are passing a member function pointer which cannot be cast or used as a global or static c-style function. This is because the calling convention of the member function (__thiscall) differs from the __cdecl convention required by LUA. You will need to use either static/global functions or another method to call member functions.
Class and pointer problems
Thanks for the response, but do you know what i could do to fix this?
Because if static things cant access member functions/varibles, then how do i make the function know where the instance of E_GM is?
I think im going to have to make something global, but i dont know what.
Because if static things cant access member functions/varibles, then how do i make the function know where the instance of E_GM is?
I think im going to have to make something global, but i dont know what.
Look into the Lua registry. You can store pointers inside lua itself, which can be retrieved later from the lua_State. In some cases, upvalues might be a better choice. The lua registry can be thought of as global lua variables, hidden from the scripts itself. Upvalues can be thought of as variables bound to a closure, inaccessible from the calling code.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement