0

I am following an example in Game Coding Complete 4th Edition, which uses LuaPlus.

In the example, and in any code i have tried myself, I am unable to register a function to lua if it has a return value of LuaObject.

LuaObject myClass::CreateFromScript(void)
{
Player* pCppInstance = new Player();

LuaObject luaInstance;
luaInstance.AssignNewTable(pLuaState);

luaInstance.SetLightUserData("__object", pCppInstance);

LuaObject metaTable = pLuaState->GetGlobals().GetByName("Players");
luaInstance.SetMetaTable(metaTable);

return luaInstance;
}

and

globals.RegisterDirect("createPlayer", &myClass::CreateFromScript);

and in .h

static LuaObject                CreateFromScript(void);

The error always happens when I set the return value to LuaObject. Which is why I was unable to do this earlier when I tried returning a LuaObject with a different function in my code.

error: LuaPlusCD.h (line 158)
"no matching function for call to 'Push(lua_State*&, LuaPlus::LuaObject&)'
user50286
  • 125
  • 2
  • 6
  • This is all I could find on the matter, and I can't tell if it's the same problem. https://github.com/jjensen/luaplus51-all/issues/4 – user50286 Oct 11 '14 at 05:08
  • Just to note, I am using Lua 5.1 with the latest version of LuaPlus. I am also using Code::Blocks, GNU GCC Compiler, Mingw – user50286 Oct 11 '14 at 05:09

0 Answers0