bool LuaTable::setMetatable(const LuaTable& table) { if (!table.getReference()->isValid()) { throw LuaException("Meta table reference is not valid!"); } this->pushValue(); table.pushValue(); lua_setmetatable(_luaState, -2); lua_pop(_luaState, 1); return true; }
bool LuaFunction::setEnvironment(const LuaTable& table) { if (!table.getReference()->isValid()) { throw LuaException("Table reference is not valid!"); } this->pushValue(); table.pushValue(); bool ret = lua_setfenv(_luaState, -2) != 0; // Pop the function again lua_pop(_luaState, 1); return ret; }