Work Around For Desync

This commit is contained in:
Cooldude2606
2018-10-26 13:19:50 +01:00
parent 4fe7ec3c0a
commit d287d33e05
6 changed files with 28 additions and 2 deletions

View File

@@ -8,12 +8,14 @@
local Game = require('FactorioStdLib.Game@^0.8.0')
local Server = require('ExpGamingCore.Server@^4.0.0')
local Role -- ExpGamingCore.Role@^4.0.0
local Admin -- ExpGamingAdmin.AdminLib@^4.0.0
-- Module Define
local module_verbose = false
local ThisModule = {
on_init=function()
if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end
if loaded_modules['ExpGamingAdmin.AdminLib@^4.0.0'] then Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') end
end
}
@@ -31,6 +33,11 @@ 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 it does not for some reason
local _ENV = _ENV or setmetatable({},{__index=_G})
_ENV.Game = self._env.Game
_ENV.Role = self._env.Role
_ENV.Admin = self._env.Admin
local chache = self.data.chache[event.player_index]
if not chache then
local player = Game.get_player(event)

View File

@@ -49,6 +49,10 @@ 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 it does not for some reason
local _ENV = _ENV or setmetatable({},{__index=_G})
_ENV.Game = self._env.Game
_ENV.Role = self._env.Role
local player = Game.get_player(event)
if not player then return end
local data = self.data
@@ -60,6 +64,9 @@ 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 it does not for some reason
local _ENV = _ENV or setmetatable({},{__index=_G})
_ENV.Sync = self._env.Sync
if Sync then Sync.emit_embeded{
title='Auto Message Error',
color=Color.to_hex(defines.textcolor.bg),

View File

@@ -88,9 +88,12 @@ function popup.open(style,data,players)
Server.new_thread{
data={players=players,popup=_popup,data=data}
}:on_event('tick',function(thread)
-- the _env should be auto loaded but it does not for some reason
local _ENV = _ENV or setmetatable({},{__index=_G})
_ENV.popup = self._env.popup
if #thread.data.players == 0 then thread:close() return end
local player = table.remove(thread.data.players,1)
if _popup.left then _popup.left:close(player) end
if thread.data.popup.left then thread.data.popup.left:close(player) end
local flow = popup.flow(player)
flow.style.visible=true
local _frame = flow.add{

View File

@@ -28,6 +28,9 @@ return function(event)
-- posible error handling if needed
error(err)
end):on_event(defines.events.on_player_respawned,function(self,event)
-- the _env should be auto loaded but it does not for some reason
local _ENV = _ENV or setmetatable({},{__index=_G})
_ENV.Game = self._env.Game
if self.data.players[event.player_index] then
local remove = {}
local player = Game.get_player(event)

View File

@@ -6,6 +6,9 @@ script.on_init(function(event)
Server.new_thread{
name='afk-kick',
}:on_event('tick',function(self)
-- the _env should be auto loaded but it does not for some reason
local _ENV = _ENV or setmetatable({},{__index=_G})
_ENV.get_allowed_afk_time = self._env.get_allowed_afk_time
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)
@@ -14,6 +17,9 @@ script.on_init(function(event)
end
end
end):on_event('error',function(self,err)
-- the _env should be auto loaded but it does not for some reason
local _ENV = _ENV or setmetatable({},{__index=_G})
_ENV.Sync = self._env.Sync
if Sync then
Sync.emit_embeded{
title='Auto Kick Error',

View File

@@ -95,7 +95,7 @@ for name,group in pairs(_root_list) do
data=element
}:on_event('timeout',function(self)
if self.data and self.data.valid then
element.parent.parent['game-settings-are-you-sure'].state = false
self.data.parent.parent['game-settings-are-you-sure'].state = false
self.data.parent.style.visible = false
self.data.state = false
end