my code (partial) c++:
lua_register(L, "GetPosition", lua_GetPosition);
int lua_GetPosition(lua_State* L)
{
Entity e = static_cast<Entity>(lua_tointeger(L, 1));
TransformComponent* trans = TransformComponentPool.GetComponentByEntity(e);
if (trans != nullptr)
{
lua_pushnumber(L, trans->transform->position.x);
lua_pushnumber(L, trans->transform->position.y);
lua_pushnumber(L, trans->transform->position.z);
}
else
{
lua_pushnumber(L, 0);
lua_pushnumber(L,0);
lua_pushnumber(L, 0);
LOG_ERROR("Transform not found");
}
return 1;
}
lua:
local x = 69
local y = 69
local z = 69
x,y,z = GetPosition(e)
print("xyz =",x,y,z)
I expected "xyz = 1.0 1.0 1.0" I got "xyz = 1.0 nil nil"
What's the right way to do this so lua sees all return values?