I just downloaded LuaBridge today and am very pleased with it so far. One thing I noticed is that I can get around the normal requirement of having lua_State as a function parameter.
I can do it:
//C++ files void love(int i) {std::cout << i;} luabridge::getGlobalNamespace(lua) .addFunction("love", love); -- Lua file love(8)
and it will work fine, but if I do something:
//C++ files struct Tester { int number; void MemFunction (int i) { std::cout << i;} static void Register(lua_State*); }; void Tester::Register(lua_State *lua) { luabridge::getGlobalNamespace(lua) .beginClass<Tester>("Tester") .addConstructor <void (*) (void)> () .addData("number", &Tester::number) .addFunction("MemFunction", &Tester::MemFunction) .endClass(); } --Lua file c = Tester() -- works... c.number = 1 -- works... c.MemFunction(10) -- nothing!
Nothing I read in the documentation indicates that member functions with non-lua_State arguments cannot be registered, and I saw some LuaBridge codes do this without problems. What am I doing wrong here?
source share