[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Question about passing a pointer to an object as parameter to Lua
- From: pixellent@...
- Date: Fri, 20 Dec 2002 13:18:15 -0500
I have a simple class called baseObject:
namespace Mike
{
class baseObject
{
public:
baseObject();
virtual ~baseObject();
void SetAge(int age);
int GetAge();
int mAge;
};
}
I've creating the binding using ToLua and everything compiles. Now I create an
instance of the baseObject and set it's age:
baseObject* bo = new baseObject();
bo->SetAge(10);
Bow I want to pass the bo object into this Lua script:
function test(bo)
age = bo:GetAge()
write ("Age = ", age, "\n")
return
end
So I do the following:
lua_getglobal(mLuaState, "test");
lua_pushusertag(mLuaState, (void*)bo, tolua_tag(mLuaState, "baseObject"));
lua_call(mLuaState, 1, 1);
But nothing happens. I'm assuming that the parameter passed into the script is junk.
Am I not understanding how this works, or am I almost right?
Any help greatly appreciated.
Thanks
Mike