Move objects from global table to internal registery

This commit is contained in:
Rochet2
2016-02-24 23:01:11 +02:00
parent 849d26e3a0
commit d162ae4105
2 changed files with 11 additions and 7 deletions

View File

@@ -242,7 +242,7 @@ void Eluna::OpenLua()
lua_pushstring(L, "v");
lua_setfield(L, -2, "__mode");
lua_setmetatable(L, -2);
lua_setglobal(L, ELUNA_OBJECT_STORE);
lua_setfield(L, LUA_REGISTRYINDEX, ELUNA_OBJECT_STORE);
// Set lua require folder paths (scripts folder structure)
lua_getglobal(L, "package");
@@ -534,7 +534,8 @@ void Eluna::RunScripts()
void Eluna::InvalidateObjects()
{
lua_getglobal(L, ELUNA_OBJECT_STORE);
lua_pushstring(L, ELUNA_OBJECT_STORE);
lua_rawget(L, LUA_REGISTRYINDEX);
ASSERT(lua_istable(L, -1));
lua_pushnil(L);