diff --git a/modules/DeconControl/control.lua b/modules/DeconControl/control.lua index 98ccec43..86ff6a00 100644 --- a/modules/DeconControl/control.lua +++ b/modules/DeconControl/control.lua @@ -33,8 +33,8 @@ Event.register(-1,function(event) if tree and tree.valid then tree.destroy() end end end):on_event(defines.events.on_marked_for_deconstruction,function(self,event) - -- the _env should be auto loaded but it does not for some reason - local _ENV = self._env.setmetatable({self=self,event=event},{__index=self._env}) + -- the _env should be auto loaded but it does not for some reasonm this is an attempt to repair the upvalues + for index,name in pairs(self._env._order) do self._env.debug.setupvalue(1,index,self._env[name]) end local chache = self.data.chache[event.player_index] if not chache then local player = Game.get_player(event) diff --git a/modules/ExpGamingBot/autoMessage/control.lua b/modules/ExpGamingBot/autoMessage/control.lua index 8284fc12..336d5a99 100644 --- a/modules/ExpGamingBot/autoMessage/control.lua +++ b/modules/ExpGamingBot/autoMessage/control.lua @@ -62,8 +62,8 @@ script.on_init(function(event) player_return({'ExpGamingBot-autoMessage.message',message},nil,player) end end):on_event('error',function(self,err) - -- the _env should be auto loaded but it does not for some reason - local _ENV = self._env.setmetatable({self=self,event=event},{__index=self._env}) + -- the _env should be auto loaded but it does not for some reasonm this is an attempt to repair the upvalues + for index,name in pairs(self._env._order) do self._env.debug.setupvalue(1,index,self._env[name]) end if Sync then Sync.emit_embeded{ title='Auto Message Error', color=Color.to_hex(defines.textcolor.bg), diff --git a/modules/ExpGamingCore/Gui/src/popup.lua b/modules/ExpGamingCore/Gui/src/popup.lua index 006c45ac..7be39860 100644 --- a/modules/ExpGamingCore/Gui/src/popup.lua +++ b/modules/ExpGamingCore/Gui/src/popup.lua @@ -88,8 +88,8 @@ function popup.open(style,data,players) Server.new_thread{ data={players=players,popup=_popup,data=data} }:on_event('tick',function(thread) - -- the _env should be auto loaded but it does not for some reason - local _ENV = self._env.setmetatable({self=self,event=event},{__index=self._env}) + -- the _env should be auto loaded but it does not for some reasonm this is an attempt to repair the upvalues + for index,name in pairs(self._env._order) do self._env.debug.setupvalue(1,index,self._env[name]) end if #thread.data.players == 0 then thread:close() return end local player = table.remove(thread.data.players,1) if thread.data.popup.left then thread.data.popup.left:close(player) end diff --git a/modules/ExpGamingCore/Gui/src/server.lua b/modules/ExpGamingCore/Gui/src/server.lua index 3f0837cb..b12ac674 100644 --- a/modules/ExpGamingCore/Gui/src/server.lua +++ b/modules/ExpGamingCore/Gui/src/server.lua @@ -28,8 +28,8 @@ return function(event) -- posible error handling if needed error(err) end):on_event(defines.events.on_player_respawned,function(self,event) - -- the _env should be auto loaded but it does not for some reason - local _ENV = self._env.setmetatable({self=self,event=event},{__index=self._env}) + -- the _env should be auto loaded but it does not for some reasonm this is an attempt to repair the upvalues + for index,name in pairs(self._env._order) do self._env.debug.setupvalue(1,index,self._env[name]) end if self.data.players[event.player_index] then local remove = {} local player = Game.get_player(event) diff --git a/modules/ExpGamingCore/Server/control.lua b/modules/ExpGamingCore/Server/control.lua index 8d2f6a8d..5a5a66af 100644 --- a/modules/ExpGamingCore/Server/control.lua +++ b/modules/ExpGamingCore/Server/control.lua @@ -280,7 +280,6 @@ function Server._thread:create(obj) obj._env._env = true obj._env._ENV = nil -- provents infinte recusion -- removes any modules from the _env to save space in global (less time to serizle) - obj._env.setmetatable = setmetatable obj._env._modules = {} for name,value in pairs(obj._env) do if is_type(value,'table') and value._module_name and loaded_modules[value._module_name] == value then obj._env._modules[name] = value._module_name obj._env[name] = nil end end setmetatable(obj._env,_env_metatable) diff --git a/modules/ExpGamingLib/control.lua b/modules/ExpGamingLib/control.lua index 23a9fc8d..47033683 100644 --- a/modules/ExpGamingLib/control.lua +++ b/modules/ExpGamingLib/control.lua @@ -48,11 +48,11 @@ function ExpLib.get_upvalues(level) local func = level and ExpLib.is_type(level,'function') and level or nil local level = level and ExpLib.is_type(level,'number') and level+1 or 2 func = func or debug.getinfo(level).func - local upvalues = setmetatable({},{__index=_G}) + local upvalues = setmetatable({_order={}},{__index=_G}) local i = 1 while true do local name, value = debug.getupvalue(func,i) - if not name then break else upvalues[name] = value end + if not name then break else upvalues[name] = value; table.insert(upvalues._order,name) end i=i+1 end return upvalues diff --git a/modules/ExpGamingPlayer/afkKick/src/server.lua b/modules/ExpGamingPlayer/afkKick/src/server.lua index fa774bf7..698f1069 100644 --- a/modules/ExpGamingPlayer/afkKick/src/server.lua +++ b/modules/ExpGamingPlayer/afkKick/src/server.lua @@ -6,8 +6,8 @@ script.on_init(function(event) Server.new_thread{ name='afk-kick', }:on_event('tick',function(self) - -- the _env should be auto loaded but it does not for some reason - local _ENV = self._env.setmetatable({self=self,event=event},{__index=self._env}) + -- the _env should be auto loaded but it does not for some reasonm this is an attempt to repair the upvalues + for index,name in pairs(self._env._order) do self._env.debug.setupvalue(1,index,self._env[name]) end if (game.tick%3600) ~= 0 then return end for _,player in pairs(game.connected_players) do local afk = #game.connected_players < 3 and 10 or get_allowed_afk_time(player) @@ -16,9 +16,8 @@ script.on_init(function(event) end end end):on_event('error',function(self,err) - -- the _env should be auto loaded but it does not for some reason - local _ENV = _ENV or setmetatable({},{__index=_G}) - _ENV.Sync = self._env.Sync + -- the _env should be auto loaded but it does not for some reasonm this is an attempt to repair the upvalues + for index,name in pairs(self._env._order) do self._env.debug.setupvalue(1,index,self._env[name]) end if Sync then Sync.emit_embeded{ title='Auto Kick Error',