Lua | ToLua++
Posted: Mon Apr 25, 2011 5:11 pm
Basically, I am trying to push a C object into the LUA stack but for some reason I can't seem to get this right. I've been trying to figure this small thing out for the past couple days. I'm getting fed up and I'm coming here.
In C:
Test is a registered class.
in LUA:
will not work.
but if I do this:
it does work.
I don't want to create a new object within LUA. For later cases when I'd like to pass objects like the player itself to change the member variables, I want to be able to do that easily.
In C:
Code: Select all
Test* testthis = new Test();
...
tolua_pushuserdata(Luaobj->L,(void*)&testthis);
lua_setglobal(Luaobj->L,"testthis");
in LUA:
Code: Select all
print(testthis:getX())
but if I do this:
Code: Select all
testthis = Test:new()
print(testthis:getX());
I don't want to create a new object within LUA. For later cases when I'd like to pass objects like the player itself to change the member variables, I want to be able to do that easily.