Lua | ToLua++

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Khearts
ES Beta Backer
ES Beta Backer
Posts: 50
Joined: Sun Oct 10, 2010 5:07 pm
Current Project: Super Mario Bros Clone and 3D Engine
Favorite Gaming Platforms: Dreamcast
Programming Language of Choice: C/++

Lua | ToLua++

Post 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.
N64vSNES
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Thu Aug 12, 2010 11:25 am

Re: Lua | ToLua++

Post by N64vSNES »

Why bother doing it this way anyway? Why not have tolua++ just generate it all for you and be done with?
User avatar
Khearts
ES Beta Backer
ES Beta Backer
Posts: 50
Joined: Sun Oct 10, 2010 5:07 pm
Current Project: Super Mario Bros Clone and 3D Engine
Favorite Gaming Platforms: Dreamcast
Programming Language of Choice: C/++

Re: Lua | ToLua++

Post by Khearts »

Honestly, I have no idea what you're referring to, but I'll be talking to you in IRC soon. :D
Post Reply