mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-22 15:33:12 +09:00
Fixed Manager.Sandbox
This commit is contained in:
1 parent
565de3f629
commit
e3c6d3fb4f
1 file changed
+3
-2
@@ -243,10 +243,11 @@ Manager.sandbox = setmetatable({
|
|||||||
if type(callback) == 'function' then
|
if type(callback) == 'function' then
|
||||||
-- creates a new sandbox env
|
-- creates a new sandbox env
|
||||||
local sandbox = tbl()
|
local sandbox = tbl()
|
||||||
local env = type(env) == 'table' and env or type(env) ~= 'nil' and {env} or {}
|
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
|
-- 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 old_mt = getmetatable(_G) or {}
|
||||||
setmetatable(env,{__index=sandbox})
|
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})
|
setmetatable(_G,{__index=env,__newindex=sandbox})
|
||||||
-- runs the callback
|
-- runs the callback
|
||||||
local rtn = {pcall(callback,...)}
|
local rtn = {pcall(callback,...)}
|
||||||
|
|||||||
Reference in new issue
Block a user