mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 19:45:22 +09:00
Fixed Manager.Sandbox
This commit is contained in:
@@ -243,10 +243,11 @@ Manager.sandbox = setmetatable({
|
||||
if type(callback) == 'function' then
|
||||
-- creates a new sandbox env
|
||||
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
|
||||
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})
|
||||
-- runs the callback
|
||||
local rtn = {pcall(callback,...)}
|
||||
|
||||
Reference in New Issue
Block a user