I'm not sure what your doing but if you want to associate the user data with the triangle and that with the Lua object who holds the same user data you can still use the up values.
Try something like this when you create the C-closure index.
..
lua_pushliteral(L, "__index");
lua_pushlightuserdata(L, (void*)data); <-----push ur user data here this will be upvalue #1
lua_pushcfunction(L, index);
...
now inside
static int index(lua_State* L) {
void* userData = (void*)lua_touserdata(L, lua_upvalueindex(1)); <--- this is how u can grab the upvalue from the closure
Now that you have that userData you can do whatever you want with it. It should be the exact same userdata which u pushed in with the line lua_pushlightuserdata..
Good Luck!
-ddn
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement