91 lines
1.8 KiB
Lua
91 lines
1.8 KiB
Lua
local function deepcopy(orig, copies)
|
|
copies = copies or {}
|
|
|
|
if type(orig) ~= 'table' then
|
|
return orig
|
|
elseif copies[orig] then
|
|
return copies[orig]
|
|
end
|
|
|
|
local copy = {}
|
|
copies[orig] = copy
|
|
|
|
for k, v in next, orig, nil do
|
|
local copied_key = deepcopy(k, copies)
|
|
local copied_val = deepcopy(v, copies)
|
|
copy[copied_key] = copied_val
|
|
end
|
|
|
|
return copy
|
|
end
|
|
|
|
local _VG=deepcopy(_G)
|
|
local lua = {
|
|
coroutine = true,
|
|
debug = true,
|
|
_HOST = true,
|
|
_VERSION = true,
|
|
assert = true,
|
|
collectgarbage = true,
|
|
error = true,
|
|
gcinfo = true,
|
|
getfenv = true,
|
|
getmetatable = true,
|
|
ipairs = true,
|
|
__inext = true,
|
|
load = true,
|
|
math = true,
|
|
next = true,
|
|
pairs = true,
|
|
pcall = true,
|
|
rawequal = true,
|
|
rawget = true,
|
|
rawlen = true,
|
|
rawset = true,
|
|
select = true,
|
|
setfenv = true,
|
|
setmetatable = true,
|
|
string = true,
|
|
table = true,
|
|
tonumber = true,
|
|
tostring = true,
|
|
type = true,
|
|
xpcall = true,
|
|
sleep = true
|
|
}
|
|
|
|
for i,v in pairs(_VG) do
|
|
if not lua[i] then
|
|
_VG[i]=nil
|
|
end
|
|
end
|
|
_VG._G=_VG
|
|
|
|
_VG.component={}
|
|
function _VG.component.list()
|
|
local i = 0
|
|
return function()
|
|
i=i+1
|
|
if aceVM.INTERNAL_COMPONENT_REGESTRY[i] then
|
|
return aceVM.INTERNAL_COMPONENT_REGESTRY[i]["type"], aceVM.INTERNAL_COMPONENT_REGESTRY[i]["object"]
|
|
else
|
|
return
|
|
end
|
|
end
|
|
end
|
|
|
|
function _VG.component.getFirst(type)
|
|
local object={}
|
|
for i,v in pairs(aceVM.INTERNAL_COMPONENT_REGESTRY) do
|
|
if aceVM.INTERNAL_COMPONENT_REGESTRY[i].type == type then
|
|
object=aceVM.INTERNAL_COMPONENT_REGESTRY[i]
|
|
break
|
|
end
|
|
end
|
|
return object["object"]
|
|
end
|
|
|
|
function aceVM.initVenv()
|
|
aceVM._VG = deepcopy(_VG)
|
|
end
|