From a0bb25630c9ce033c66acf771244ebb490aff109 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 25 Oct 2018 16:45:57 +0100 Subject: [PATCH] Fixed Sandbox again --- FactorioSoftmodManager.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/FactorioSoftmodManager.lua b/FactorioSoftmodManager.lua index c5c72af6..2d48ba04 100644 --- a/FactorioSoftmodManager.lua +++ b/FactorioSoftmodManager.lua @@ -246,9 +246,8 @@ Manager.sandbox = setmetatable({ local env = type(env) == 'table' and env or {} -- new indexs are saved into sandbox and if _G does not have the index then look in sandbox local old_mt = getmetatable(_G) or {} - local env_mt = getmetatable(env) or {} - setmetatable(env,{__index=function(tbl,key) return env_mt.__index and env_mt.__index(tbl,key) or sandbox[key] end}) - setmetatable(_G,{__index=env,__newindex=sandbox}) + local tmp_env = setmetatable({},{__index=function(tbl,key) return env[key] or sandbox[key] end}) + setmetatable(_G,{__index=tmp_env,__newindex=sandbox}) -- runs the callback local rtn = {pcall(callback,...)} local success = table.remove(rtn,1)