mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
4th try now :/
This commit is contained in:
@@ -249,9 +249,15 @@ Manager.sandbox = setmetatable({
|
|||||||
local tmp_env = setmetatable({},{__index=function(tbl,key) return env[key] or sandbox[key] or rawget(_G,key) end,newindex=sandbox})
|
local tmp_env = setmetatable({},{__index=function(tbl,key) return env[key] or sandbox[key] or rawget(_G,key) end,newindex=sandbox})
|
||||||
tmp_env._ENV = tmp_env
|
tmp_env._ENV = tmp_env
|
||||||
tmp_env._G_mt = _G_mt
|
tmp_env._G_mt = _G_mt
|
||||||
|
-- sets the upvalues for the function
|
||||||
|
local i = 1
|
||||||
|
while true do
|
||||||
|
local name, value = debug.getupvalue(callback,i)
|
||||||
|
if not name then break else if not value and tmp_env[name] then debug.setupvalue(callback,i,tmp_env[name]) end end
|
||||||
|
i=i+1
|
||||||
|
end
|
||||||
-- runs the callback
|
-- runs the callback
|
||||||
setmetatable(_G,{__index=tmp_env,newindex=sandbox})
|
setmetatable(_G,{__index=tmp_env,newindex=sandbox})
|
||||||
--debug.setupvalue(callback,1,tmp_env) -- this should set the value of _ENV
|
|
||||||
local rtn = {pcall(callback,...)}
|
local rtn = {pcall(callback,...)}
|
||||||
local success = table.remove(rtn,1)
|
local success = table.remove(rtn,1)
|
||||||
setmetatable(_G,_G_mt)
|
setmetatable(_G,_G_mt)
|
||||||
|
|||||||
@@ -19,42 +19,6 @@ local ThisModule = {
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
local function on_marked_for_deconstruction(self,event)
|
|
||||||
-- the _env should be auto loaded but does not, so to prevent desyncs it cant be an anon function
|
|
||||||
local chache = self.data.chache[event.player_index]
|
|
||||||
if not chache then
|
|
||||||
local player = Game.get_player(event)
|
|
||||||
if not player then return end
|
|
||||||
if not Role then
|
|
||||||
if player.admin then self.data.chache[event.player_index] = {'tree-decon',false}
|
|
||||||
else self.data.chache[event.player_index] = {'decon',false} end
|
|
||||||
else
|
|
||||||
if Role.allowed(player,'tree-decon') then self.data.chache[event.player_index] = {'tree-decon',false}
|
|
||||||
elseif not Role.allowed(player,'decon') then self.data.chache[event.player_index] = {'no-decon',false}
|
|
||||||
else self.data.chache[event.player_index] = {'decon',false} end
|
|
||||||
end
|
|
||||||
chache = self.data.chache[event.player_index]
|
|
||||||
end
|
|
||||||
if not event.entity.last_user or event.entity.name == 'entity-ghost' then
|
|
||||||
if chache[1] == 'tree-decon' then
|
|
||||||
table.insert(self.data.trees,event.entity)
|
|
||||||
self.data.clear = game.tick + 10
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if chache[1] == 'no-decon' then
|
|
||||||
event.entity.cancel_deconstruction('player')
|
|
||||||
if not chache[2] then
|
|
||||||
chache[2] = true
|
|
||||||
local player = Game.get_player(event)
|
|
||||||
player_return({'DeconControl.player-print'},defines.textcolor.crit,player)
|
|
||||||
Role.print(Role.meta.groups.Admin.lowest,{'DeconControl.rank-print',player.name},defines.textcolor.info)
|
|
||||||
if Admin then Admin.give_warning(player,'<server>','Trying To Decon The Base') end
|
|
||||||
end
|
|
||||||
self.data.clear = game.tick + 10
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Event Handlers Define
|
-- Event Handlers Define
|
||||||
Event.register(-1,function(event)
|
Event.register(-1,function(event)
|
||||||
Server.new_thread{
|
Server.new_thread{
|
||||||
@@ -68,7 +32,41 @@ Event.register(-1,function(event)
|
|||||||
local tree = table.remove(trees,1)
|
local tree = table.remove(trees,1)
|
||||||
if tree and tree.valid then tree.destroy() end
|
if tree and tree.valid then tree.destroy() end
|
||||||
end
|
end
|
||||||
end):on_event(defines.events.on_marked_for_deconstruction,on_marked_for_deconstruction):open()
|
end):on_event(defines.events.on_marked_for_deconstruction,function(self,event)
|
||||||
|
-- the _env should be auto loaded but does not, so to prevent desyncs it cant be an anon function
|
||||||
|
local chache = self.data.chache[event.player_index]
|
||||||
|
if not chache then
|
||||||
|
local player = Game.get_player(event)
|
||||||
|
if not player then return end
|
||||||
|
if not Role then
|
||||||
|
if player.admin then self.data.chache[event.player_index] = {'tree-decon',false}
|
||||||
|
else self.data.chache[event.player_index] = {'decon',false} end
|
||||||
|
else
|
||||||
|
if Role.allowed(player,'tree-decon') then self.data.chache[event.player_index] = {'tree-decon',false}
|
||||||
|
elseif not Role.allowed(player,'decon') then self.data.chache[event.player_index] = {'no-decon',false}
|
||||||
|
else self.data.chache[event.player_index] = {'decon',false} end
|
||||||
|
end
|
||||||
|
chache = self.data.chache[event.player_index]
|
||||||
|
end
|
||||||
|
if not event.entity.last_user or event.entity.name == 'entity-ghost' then
|
||||||
|
if chache[1] == 'tree-decon' then
|
||||||
|
table.insert(self.data.trees,event.entity)
|
||||||
|
self.data.clear = game.tick + 10
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if chache[1] == 'no-decon' then
|
||||||
|
event.entity.cancel_deconstruction('player')
|
||||||
|
if not chache[2] then
|
||||||
|
chache[2] = true
|
||||||
|
local player = Game.get_player(event)
|
||||||
|
player_return({'DeconControl.player-print'},defines.textcolor.crit,player)
|
||||||
|
Role.print(Role.meta.groups.Admin.lowest,{'DeconControl.rank-print',player.name},defines.textcolor.info)
|
||||||
|
if Admin then Admin.give_warning(player,'<server>','Trying To Decon The Base') end
|
||||||
|
end
|
||||||
|
self.data.clear = game.tick + 10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end):open()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Module Return
|
-- Module Return
|
||||||
|
|||||||
@@ -74,7 +74,29 @@ script.on_init(function(event)
|
|||||||
game.print{'ExpGamingBot-autoMessage.message',{'ExpGamingBot-autoMessage.players-online',#game.connected_players}}
|
game.print{'ExpGamingBot-autoMessage.message',{'ExpGamingBot-autoMessage.players-online',#game.connected_players}}
|
||||||
game.print{'ExpGamingBot-autoMessage.message',{'ExpGamingBot-autoMessage.map-time',tick_to_display_format(game.tick)}}
|
game.print{'ExpGamingBot-autoMessage.message',{'ExpGamingBot-autoMessage.map-time',tick_to_display_format(game.tick)}}
|
||||||
self.reopen = true
|
self.reopen = true
|
||||||
end):on_event(defines.events.on_player_joined_game,on_player_joined_game):on_event('error',on_error):open()
|
end):on_event(defines.events.on_player_joined_game,function(self,event)
|
||||||
|
-- the _env should be auto loaded but does not, so to prevent desyncs it cant be an anon function
|
||||||
|
local player = Game.get_player(event)
|
||||||
|
if not player then return end
|
||||||
|
local data = self.data
|
||||||
|
if not data.high_role or not data.low_role
|
||||||
|
or not data.low then self.reopen = false return end
|
||||||
|
-- idk but this stoped working for no appent reason so i added more checks for nil values
|
||||||
|
if Role and Role.get_highest(player).index <= Role.get(data.low_role).index or player.admin then return end
|
||||||
|
for _,message in pairs(data.low) do
|
||||||
|
player_return({'ExpGamingBot-autoMessage.message',message},nil,player)
|
||||||
|
end
|
||||||
|
end):on_event('error',function(self,err)
|
||||||
|
-- the _env should be auto loaded but does not, so to prevent desyncs it cant be an anon function
|
||||||
|
if Sync then Sync.emit_embeded{
|
||||||
|
title='Auto Message Error',
|
||||||
|
color=Color.to_hex(defines.textcolor.bg),
|
||||||
|
description='Auto Message Error - Closed Thread',
|
||||||
|
Error=err
|
||||||
|
} end
|
||||||
|
self.reopen = false
|
||||||
|
self:close()
|
||||||
|
end):open()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Module Return
|
-- Module Return
|
||||||
|
|||||||
@@ -111,7 +111,30 @@ function popup.open(style,data,players)
|
|||||||
end
|
end
|
||||||
Server.new_thread{
|
Server.new_thread{
|
||||||
data={players=players,popup=_popup,data=data}
|
data={players=players,popup=_popup,data=data}
|
||||||
}:on_event('tick',on_tick):open()
|
}:on_event('tick',function(self)
|
||||||
|
-- the _env should be auto loaded but does not, so to prevent desyncs it cant be an anon function
|
||||||
|
if #self.data.players == 0 then self:close() return end
|
||||||
|
local player = table.remove(self.data.players,1)
|
||||||
|
if self.data.popup.left then self.data.popup.left:close(player) end
|
||||||
|
local flow = popup.flow(player)
|
||||||
|
flow.style.visible=true
|
||||||
|
local _frame = flow.add{
|
||||||
|
type='frame',
|
||||||
|
direction='horizontal',
|
||||||
|
style=mod_gui.frame_style
|
||||||
|
}
|
||||||
|
local frame = _frame.add{
|
||||||
|
type='frame',
|
||||||
|
name='inner_frame',
|
||||||
|
direction='vertical',
|
||||||
|
style='image_frame'
|
||||||
|
}
|
||||||
|
self.data.popup.close(_frame)
|
||||||
|
if is_type(self.data.popup.draw,'function') then
|
||||||
|
local success, err = pcall(self.data.popup.draw,frame,self.data.data)
|
||||||
|
if not success then error(err) end
|
||||||
|
else error('No Draw On Popup '..self.data.popup.name) end
|
||||||
|
end):open()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -39,5 +39,18 @@ return function(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.data.cam_index = self.data.cam_index+update
|
self.data.cam_index = self.data.cam_index+update
|
||||||
end):on_event(defines.events.on_player_respawned,on_player_respawned):open()
|
end):on_event(defines.events.on_player_respawned,function(self,event)
|
||||||
|
-- the _env should be auto loaded but does not, so to prevent desyncs it cant be an anon function
|
||||||
|
if self.data.players[event.player_index] then
|
||||||
|
local remove = {}
|
||||||
|
local player = Game.get_player(event)
|
||||||
|
for index,cam in pairs(self.data.players[event.player_index]) do
|
||||||
|
if cam.valid then table.insert(self.data.cams,{cam=cam,entity=player.character,surface=player.surface})
|
||||||
|
else table.insert(remove,index) end
|
||||||
|
end
|
||||||
|
for n,index in pairs(remove) do
|
||||||
|
table.remove(self.data.players[event.player_index],index-n+1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end):open()
|
||||||
end
|
end
|
||||||
@@ -48,11 +48,11 @@ function ExpLib.get_upvalues(level)
|
|||||||
local func = level and ExpLib.is_type(level,'function') and level or nil
|
local func = level and ExpLib.is_type(level,'function') and level or nil
|
||||||
local level = level and ExpLib.is_type(level,'number') and level+1 or 2
|
local level = level and ExpLib.is_type(level,'number') and level+1 or 2
|
||||||
func = func or debug.getinfo(level).func
|
func = func or debug.getinfo(level).func
|
||||||
local upvalues = setmetatable({_order={}},{__index=_G})
|
local upvalues = setmetatable({},{__index=_G})
|
||||||
local i = 1
|
local i = 1
|
||||||
while true do
|
while true do
|
||||||
local name, value = debug.getupvalue(func,i)
|
local name, value = debug.getupvalue(func,i)
|
||||||
if not name then break else upvalues[name] = value; table.insert(upvalues._order,name) end
|
if not name then break else upvalues[name] = value end
|
||||||
i=i+1
|
i=i+1
|
||||||
end
|
end
|
||||||
return upvalues
|
return upvalues
|
||||||
|
|||||||
@@ -30,6 +30,24 @@ end
|
|||||||
script.on_init(function(event)
|
script.on_init(function(event)
|
||||||
Server.new_thread{
|
Server.new_thread{
|
||||||
name='afk-kick',
|
name='afk-kick',
|
||||||
}:on_event('tick',on_tick):on_event('error',function(self,err)
|
}:on_event('tick',function(self)
|
||||||
):open()
|
-- the _env should be auto loaded but does not, so to prevent desyncs it cant be an anon function
|
||||||
|
if (game.tick%3600) ~= 0 then return end
|
||||||
|
for _,player in pairs(game.connected_players) do
|
||||||
|
local afk = #game.connected_players < 3 and 10 or get_allowed_afk_time(player)
|
||||||
|
if afk then
|
||||||
|
if player.afk_time > afk*3600 then game.kick_player(player,'AFK For Too Long ('..math.floor(afk)..' Minutes)') end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end):on_event('error',function(self,err)
|
||||||
|
if Sync then
|
||||||
|
Sync.emit_embeded{
|
||||||
|
title='Auto Kick Error',
|
||||||
|
color=Color.to_hex(defines.textcolor.bg),
|
||||||
|
description='Auto Kick Error - Closed Thread',
|
||||||
|
Error=err
|
||||||
|
}
|
||||||
|
end
|
||||||
|
self:close()
|
||||||
|
end):open()
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user