lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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