mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 19:45:22 +09:00
Fixed Manager.sandbox to work with upvalues
This commit is contained in:
@@ -33,7 +33,6 @@ Event.register(-1,function(event)
|
||||
if tree and tree.valid then tree.destroy() end
|
||||
end
|
||||
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)
|
||||
|
||||
@@ -24,32 +24,6 @@ local ThisModule = {
|
||||
end
|
||||
}
|
||||
|
||||
local function on_player_joined_game(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
|
||||
|
||||
local function on_error(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
|
||||
|
||||
-- Event Handlers Define
|
||||
script.on_init(function(event)
|
||||
Server.new_thread{
|
||||
@@ -75,7 +49,6 @@ script.on_init(function(event)
|
||||
game.print{'ExpGamingBot-autoMessage.message',{'ExpGamingBot-autoMessage.map-time',tick_to_display_format(game.tick)}}
|
||||
self.reopen = true
|
||||
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
|
||||
@@ -87,7 +60,6 @@ script.on_init(function(event)
|
||||
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),
|
||||
|
||||
@@ -67,12 +67,12 @@ function left.update(frame,players)
|
||||
local frames = Gui.data.left or {}
|
||||
if frame then frames = {[frame]=frames[frame]} or {} end
|
||||
local players = is_type(players,'table') and #players > 0 and {unpack(players)} or is_type(players,'table') and {players} or Game.get_player(players) and {Game.get_player(players)} or game.connected_players
|
||||
Server.new_thread{
|
||||
|
||||
data={players=players,frames=frames}
|
||||
}:on_event('tick',function(thread)
|
||||
if #thread.data.players == 0 then thread:close() return end
|
||||
local player = table.remove(thread.data.players,1)
|
||||
Server.new_thread{
|
||||
|
||||
data={player=player,frames=thread.data.frames}
|
||||
}:on_event('resolve',function(thread)
|
||||
for name,left in pairs(thread.data.frames) do
|
||||
@@ -94,7 +94,7 @@ function left.open(left_name,player)
|
||||
if not Server or not Server._thread then
|
||||
for _,player in pairs(players) do _left:open(player) end
|
||||
else
|
||||
Server.new_thread{
|
||||
|
||||
data={players=players}
|
||||
}:on_event('tick',function(thread)
|
||||
if #thread.data.players == 0 then thread:close() return end
|
||||
@@ -115,7 +115,7 @@ function left.close(left_name,player)
|
||||
if not Server or not Server._thread or player then
|
||||
for _,player in pairs(players) do _left:close(player) end
|
||||
else
|
||||
Server.new_thread{
|
||||
|
||||
data={players=players}
|
||||
}:on_event('tick',function(thread)
|
||||
if #thread.data.players == 0 then thread:close() return end
|
||||
|
||||
@@ -85,34 +85,9 @@ function popup.open(style,data,players)
|
||||
else error('No Draw On Popup '.._popup.name) end
|
||||
end
|
||||
else
|
||||
local function on_tick(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
|
||||
Server.new_thread{
|
||||
data={players=players,popup=_popup,data=data}
|
||||
}: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
|
||||
|
||||
@@ -6,21 +6,6 @@ local Server = require('ExpGamingCore.Server@^4.0.0')
|
||||
|
||||
Server.add_module_to_interface('ExpGui','ExpGamingCore.Gui')
|
||||
|
||||
local function on_player_respawned(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
|
||||
|
||||
--- Adds a server thread that allows the camera follows to be toggled off and on
|
||||
return function(event)
|
||||
Server.new_thread{
|
||||
@@ -40,7 +25,6 @@ return function(event)
|
||||
end
|
||||
self.data.cam_index = self.data.cam_index+update
|
||||
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)
|
||||
|
||||
@@ -3,35 +3,10 @@ local get_allowed_afk_time = self
|
||||
local Server = require('ExpGamingCore.Server@^4.0.0')
|
||||
Event[defines.events.on_tick] = nil
|
||||
|
||||
local function on_tick(self)
|
||||
-- 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
|
||||
|
||||
local function on_error(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 Kick Error',
|
||||
color=Color.to_hex(defines.textcolor.bg),
|
||||
description='Auto Kick Error - Closed Thread',
|
||||
Error=err
|
||||
}
|
||||
end
|
||||
self:close()
|
||||
end
|
||||
|
||||
script.on_init(function(event)
|
||||
Server.new_thread{
|
||||
name='afk-kick',
|
||||
}: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 (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)
|
||||
|
||||
Reference in New Issue
Block a user