[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Pointer and Userdata
- From: Initial-N <neruson_newsletter@...>
- Date: Mon, 27 Dec 2004 08:28:46 -0500 (EST)
I use tolua to bind my C++ class to lua.
However, (looking through everywhere on website, ML, and tutorial), I could not figure out how to associate the object pointer and object's methods/fields.
In Lua script:
_OnEnter_ = function(param)
local o = GetObjectFromPointer(param);
somewhere in native code,
I call this lua function,
Object *o = new Object();
lua_call(mLuaState, 1, 0);
And I have registered function,
static int Native_GetObjectFrPtr(lua_State *L)
Object *myObjPtr = (Object *)lua_touserdata(L, -1);
I'm sure the correct address (pointer to the object)is successfully passed to lua stack, but I keep getting the error message that complain I attemp to index local 'o' (a userdta value).
There must be something I miss which probably need to pass tag to lua.
I have to to use Lua 4 , therefore, it become more difficult for me to figure out how this works.
I would very much appreciate if someone can help me out with this problem.
Post your free ad now! Yahoo! Canada Personals