Page 1 of 1

Lua | ToLua++

Posted: Mon Apr 25, 2011 5:11 pm
by Khearts
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. :evil:

In C:

Code: Select all


Test* testthis = new Test();
...
tolua_pushuserdata(Luaobj->L,(void*)&testthis);
lua_setglobal(Luaobj->L,"testthis");
Test is a registered class.

in LUA:

Code: Select all

print(testthis:getX())
will not work.

but if I do this:

Code: Select all

testthis = Test:new()
print(testthis:getX());
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.

Re: Lua | ToLua++

Posted: Mon Apr 25, 2011 7:01 pm
by N64vSNES
Why bother doing it this way anyway? Why not have tolua++ just generate it all for you and be done with?

Re: Lua | ToLua++

Posted: Mon Apr 25, 2011 9:57 pm
by Khearts
Honestly, I have no idea what you're referring to, but I'll be talking to you in IRC soon. :D