mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Few Bug Fixes
This commit is contained in:
@@ -160,7 +160,7 @@ Manager.verbose('The verbose state is: '..tostring(Manager.setVerbose.selfInit),
|
|||||||
-- @treturn table the new global table for that module
|
-- @treturn table the new global table for that module
|
||||||
Manager.global=setmetatable({__defaults={},__global={
|
Manager.global=setmetatable({__defaults={},__global={
|
||||||
__call=function(tbl,default) return Manager.global(default) end,
|
__call=function(tbl,default) return Manager.global(default) end,
|
||||||
__index=function(tbl,key) return Manager.global() == tbl and nil or rawget(Manager.global(),key) or tbl(key) end,
|
__index=function(tbl,key) return rawget(Manager.global(),key) or tbl(key) end,
|
||||||
__newindex=function(tbl,key,value) rawset(Manager.global(),key,value) end,
|
__newindex=function(tbl,key,value) rawset(Manager.global(),key,value) end,
|
||||||
__pairs=function(tbl)
|
__pairs=function(tbl)
|
||||||
local tbl = Manager.global()
|
local tbl = Manager.global()
|
||||||
@@ -171,12 +171,13 @@ Manager.global=setmetatable({__defaults={},__global={
|
|||||||
return next_pair, tbl, nil
|
return next_pair, tbl, nil
|
||||||
end
|
end
|
||||||
}},{
|
}},{
|
||||||
__call=function(tbl,default)
|
__call=function(tbl,default,tbl2)
|
||||||
local global = _G.global
|
local global = _G.global
|
||||||
local module_name = type(default) == 'string' and default or module_name
|
local tbl2 = type(tbl2) == 'table' and getmetatable(tbl2) or nil
|
||||||
local module_path = type(default) == 'string' and moduleIndex[default] or module_path
|
local module_name = type(default) == 'string' and default or tbl2 and tbl2.name or module_name
|
||||||
|
local module_path = type(default) == 'string' and moduleIndex[default] or tbl2 and tbl2.path or module_path
|
||||||
if not module_path or not module_name then return _G.global end
|
if not module_path or not module_name then return _G.global end
|
||||||
if type(default) == 'table' then rawset(rawget(tbl,'__defaults'),tostring(module_name),default) end
|
if type(default) == 'table' then Manager.verbose('Default global has been set for: global'..module_path:gsub('/','.')) rawset(rawget(tbl,'__defaults'),tostring(module_name),default) end
|
||||||
local path = 'global'
|
local path = 'global'
|
||||||
local new_dir = false
|
local new_dir = false
|
||||||
for dir in module_path:gmatch('%a+') do
|
for dir in module_path:gmatch('%a+') do
|
||||||
@@ -185,10 +186,17 @@ Manager.global=setmetatable({__defaults={},__global={
|
|||||||
global = rawget(global,dir)
|
global = rawget(global,dir)
|
||||||
end
|
end
|
||||||
if (new_dir or default == true) and rawget(rawget(tbl,'__defaults'),tostring(module_name)) then
|
if (new_dir or default == true) and rawget(rawget(tbl,'__defaults'),tostring(module_name)) then
|
||||||
Manager.verbose('Set Global Dir: '..path..' to its default')
|
Manager.verbose('Set Global Dir: '..path..' to its default')
|
||||||
for key,value in pairs(rawget(rawget(tbl,'__defaults'),tostring(module_name))) do rawset(global,key,value) end
|
-- cant set it to be equle otherwise it will lose its global propeity
|
||||||
|
local function deepcopy(tbl) if type(tbl) ~= 'table' then return tbl end local rtn = {} for key,value in pairs(tbl) do rtn[key] = deepcopy(value) end return rtn end
|
||||||
|
for key,value in pairs(global) do rawset(global,key,nil) end
|
||||||
|
for key,value in pairs(rawget(rawget(tbl,'__defaults'),tostring(module_name))) do rawset(global,key,deepcopy(value)) end
|
||||||
end
|
end
|
||||||
return global
|
return setmetatable(global,{
|
||||||
|
__call=function(tbl,default) return Manager.global(default,tbl) end,
|
||||||
|
__index=function(tbl,key) return rawget(Manager.global(),key) or tbl(key) end,
|
||||||
|
path=module_path,name=module_name
|
||||||
|
})
|
||||||
end,
|
end,
|
||||||
__index=function(tbl,key) return rawget(tbl(),key) or rawget(_G.global,key) or tbl(key) end,
|
__index=function(tbl,key) return rawget(tbl(),key) or rawget(_G.global,key) or tbl(key) end,
|
||||||
__newindex=function(tbl,key,value) rawset(tbl(),key,value) end,
|
__newindex=function(tbl,key,value) rawset(tbl(),key,value) end,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
local Gui = {}
|
local Gui = {}
|
||||||
local Gui_data = {}
|
local Gui_data = {}
|
||||||
|
local global = global()
|
||||||
--- Used to set and get data about different guis
|
--- Used to set and get data about different guis
|
||||||
-- @usage Gui.data[location] -- returns the gui data for that gui location ex center
|
-- @usage Gui.data[location] -- returns the gui data for that gui location ex center
|
||||||
-- @usage Gui.data(location,gui_name,gui_data) -- adds gui data for a gui at a location
|
-- @usage Gui.data(location,gui_name,gui_data) -- adds gui data for a gui at a location
|
||||||
@@ -94,21 +94,21 @@ function Gui.cam_link(data)
|
|||||||
data.cam.style.height = data.height or 100
|
data.cam.style.height = data.height or 100
|
||||||
else return end
|
else return end
|
||||||
if not Server or not Server._thread or not Server.get_thread('camera-follow') then
|
if not Server or not Server._thread or not Server.get_thread('camera-follow') then
|
||||||
if not global().cams then
|
if not global.cams then
|
||||||
global().cams = {}
|
global.cams = {}
|
||||||
global().cam_index = 1
|
global.cam_index = 1
|
||||||
end
|
end
|
||||||
if data.cam then
|
if data.cam then
|
||||||
local surface = data.surface and data.surface.index or nil
|
local surface = data.surface and data.surface.index or nil
|
||||||
table.insert(global().cams,{cam=data.cam,entity=data.entity,surface=surface})
|
table.insert(global.cams,{cam=data.cam,entity=data.entity,surface=surface})
|
||||||
end
|
end
|
||||||
if not global().players then
|
if not global.players then
|
||||||
global().players = {}
|
global.players = {}
|
||||||
end
|
end
|
||||||
if data.respawn_open then
|
if data.respawn_open then
|
||||||
if data.entity.player then
|
if data.entity.player then
|
||||||
if not global().players[data.entity.player.index] then global().players[data.entity.player.index] = {} end
|
if not global.players[data.entity.player.index] then global.players[data.entity.player.index] = {} end
|
||||||
table.insert(global().players[data.entity.player.index],data.cam)
|
table.insert(global.players[data.entity.player.index],data.cam)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -135,26 +135,26 @@ script.on_event('on_tick', function(event)
|
|||||||
if Gui.left and ((event.tick+10)/(3600*game.speed)) % 15 == 0 then
|
if Gui.left and ((event.tick+10)/(3600*game.speed)) % 15 == 0 then
|
||||||
Gui.left.update()
|
Gui.left.update()
|
||||||
end
|
end
|
||||||
if global().cams and is_type(global().cams,'table') and #global().cams > 0 then
|
if global.cams and is_type(global.cams,'table') and #global.cams > 0 then
|
||||||
local _cam = global().cams[global().cam_index]
|
local _cam = global.cams[global.cam_index]
|
||||||
if not _cam then global().cam_index = 1 _cam = global().cams[global().cam_index] end
|
if not _cam then global.cam_index = 1 _cam = global.cams[global.cam_index] end
|
||||||
if not _cam then return end
|
if not _cam then return end
|
||||||
if not _cam.cam.valid then table.remove(global().cams,global().cam_index)
|
if not _cam.cam.valid then table.remove(global.cams,global.cam_index)
|
||||||
elseif not _cam.entity.valid then table.remove(global().cams,global().cam_index)
|
elseif not _cam.entity.valid then table.remove(global.cams,global.cam_index)
|
||||||
else _cam.cam.position = _cam.entity.position if not _cam.surface then _cam.cam.surface_index = _cam.entity.surface.index end global().cam_index = global().cam_index+1
|
else _cam.cam.position = _cam.entity.position if not _cam.surface then _cam.cam.surface_index = _cam.entity.surface.index end global.cam_index = global.cam_index+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
script.on_event('on_player_respawned',function(event)
|
script.on_event('on_player_respawned',function(event)
|
||||||
if global().players and is_type(global().players,'table') and #global().players > 0 and global().players[event.player_index] then
|
if global.players and is_type(global.players,'table') and #global.players > 0 and global.players[event.player_index] then
|
||||||
local remove = {}
|
local remove = {}
|
||||||
for index,cam in pairs(global().players[event.player_index]) do
|
for index,cam in pairs(global.players[event.player_index]) do
|
||||||
Gui.cam_link{cam=cam,entity=Game.get_player(event).character}
|
Gui.cam_link{cam=cam,entity=Game.get_player(event).character}
|
||||||
if not cam.valid then table.insert(remove,index) end
|
if not cam.valid then table.insert(remove,index) end
|
||||||
end
|
end
|
||||||
for _,index in pairs(remove) do
|
for _,index in pairs(remove) do
|
||||||
table.remove(global().players[event.player_index],index)
|
table.remove(global.players[event.player_index],index)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ left._left = {}
|
|||||||
|
|
||||||
-- used for debugging
|
-- used for debugging
|
||||||
function left.override_open(state)
|
function left.override_open(state)
|
||||||
global().over_ride_left_can_open = state
|
global.over_ride_left_can_open = state
|
||||||
end
|
end
|
||||||
--- Used to add a left gui frame
|
--- Used to add a left gui frame
|
||||||
-- @usage Gui.left.add{name='foo',caption='Foo',tooltip='just testing',open_on_join=true,can_open=function,draw=function}
|
-- @usage Gui.left.add{name='foo',caption='Foo',tooltip='just testing',open_on_join=true,can_open=function,draw=function}
|
||||||
@@ -143,7 +143,7 @@ function left._left.toggle(event)
|
|||||||
local success, err = pcall(_left.can_open,player)
|
local success, err = pcall(_left.can_open,player)
|
||||||
if not success then error(err)
|
if not success then error(err)
|
||||||
elseif err == true then open = true
|
elseif err == true then open = true
|
||||||
elseif global().over_ride_left_can_open then
|
elseif global.over_ride_left_can_open then
|
||||||
if is_type(Ranking,'table') and Ranking.meta.rank_count > 0 then
|
if is_type(Ranking,'table') and Ranking.meta.rank_count > 0 then
|
||||||
if Ranking.get_rank(player):allowed(_left.name) then open = true
|
if Ranking.get_rank(player):allowed(_left.name) then open = true
|
||||||
else open = {gui.unauthorized} end
|
else open = {gui.unauthorized} end
|
||||||
|
|||||||
@@ -48,13 +48,15 @@ end)
|
|||||||
Server.threads = setmetatable({},{
|
Server.threads = setmetatable({},{
|
||||||
__metatable=false,
|
__metatable=false,
|
||||||
__call=function(tbl) return global.all._n end,
|
__call=function(tbl) return global.all._n end,
|
||||||
|
__len=function(tbl) return global.all._n end,
|
||||||
__index=function(tbl,key) return rawget(global.all,key) end,
|
__index=function(tbl,key) return rawget(global.all,key) end,
|
||||||
__newindex=function(tbl,key,value) rawset(global.all,key,value) end,
|
__newindex=function(tbl,key,value) rawset(global.all,key,value) end,
|
||||||
__pairs=function(tbl)
|
__pairs=function(tbl)
|
||||||
local tbl = global.all
|
local tbl = global.all
|
||||||
local function next_pair(tbl,k)
|
local function next_pair(tbl,k)
|
||||||
k, v = next(tbl, k)
|
k, v = next(tbl, k)
|
||||||
if type(v) ~= nil and k ~= '_n' then return k,v end
|
if type(v) ~= nil and k ~= '_n' then return k,v
|
||||||
|
else return next(tbl, k) end
|
||||||
end
|
end
|
||||||
return next_pair, tbl, nil
|
return next_pair, tbl, nil
|
||||||
end
|
end
|
||||||
@@ -97,7 +99,7 @@ end
|
|||||||
function Server.close_all_threads(with_force)
|
function Server.close_all_threads(with_force)
|
||||||
if not with_force then
|
if not with_force then
|
||||||
for uuid,thread in pairs(Server.threads) do thread:close() end
|
for uuid,thread in pairs(Server.threads) do thread:close() end
|
||||||
else global(true) end
|
else global.Server(true) end -- idk why you cant just use global even when global is defined at the top to be over ridren
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Runs all the theads which have opened with an on_tick event
|
--- Runs all the theads which have opened with an on_tick event
|
||||||
@@ -227,11 +229,11 @@ function Server.interface(callback,use_thread,env,...)
|
|||||||
end
|
end
|
||||||
if is_type(env,'table') and env._env == true then
|
if is_type(env,'table') and env._env == true then
|
||||||
local sandbox, success, err = Manager.sandbox(_callback,env,...)
|
local sandbox, success, err = Manager.sandbox(_callback,env,...)
|
||||||
if not success then error(err) return success,err
|
if not success then return success,err
|
||||||
else return success, unpack(err) end
|
else return success, unpack(err) end
|
||||||
else
|
else
|
||||||
local sandbox, success, err = Manager.sandbox(_callback,{},env,...)
|
local sandbox, success, err = Manager.sandbox(_callback,{},env,...)
|
||||||
if not success then error(err) return success,err
|
if not success then return success,err
|
||||||
else return success, unpack(err) end
|
else return success, unpack(err) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -194,6 +194,7 @@ end
|
|||||||
-- @tparam table tbl table to convert
|
-- @tparam table tbl table to convert
|
||||||
-- @treturn string the converted table
|
-- @treturn string the converted table
|
||||||
function table.tostring(tbl)
|
function table.tostring(tbl)
|
||||||
|
if type(tbl) ~= 'table' then return tostring(tbl) end
|
||||||
local result, done = {}, {}
|
local result, done = {}, {}
|
||||||
for k, v in ipairs(tbl) do
|
for k, v in ipairs(tbl) do
|
||||||
table.insert(result,table.val_to_str(v))
|
table.insert(result,table.val_to_str(v))
|
||||||
|
|||||||
Reference in New Issue
Block a user