mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-29 20:16:38 +09:00
Covnerted Event and Global
This commit is contained in:
@@ -24,7 +24,7 @@ local module_verbose = false --true|false
|
||||
-- @field ranks a list of player ranks
|
||||
-- @field rockets the number of rockets launched
|
||||
-- @field mods the mods which are loaded
|
||||
local global = global{
|
||||
local global = {
|
||||
server_name='Factorio Server',
|
||||
server_description='A factorio server for everyone',
|
||||
reset_time='On Demand',
|
||||
@@ -47,6 +47,7 @@ local global = global{
|
||||
rockets=0,
|
||||
mods={'Offline'}
|
||||
}
|
||||
Global.register(global,function(tbl) global = tbl end)
|
||||
|
||||
--- Player sub-table
|
||||
-- @table global.players
|
||||
@@ -316,14 +317,14 @@ Sync.time=add_metatable({},function(full,date)
|
||||
end,function() local info = Sync.info return info.time..' (+'..(game.tick-info.time_set[1])..' Ticks)' end)
|
||||
|
||||
-- will auto replace the file every 5 min by default
|
||||
script.on_event('on_tick',function(event)
|
||||
Event.add('on_tick',function(event)
|
||||
local time = Sync.info.time_period[1]
|
||||
if (event.tick%time)==0 then Sync.emit_update() end
|
||||
end)
|
||||
|
||||
script.on_event('on_player_joined_game',Sync.emit_update)
|
||||
script.on_event('on_pre_player_left_game',Sync.emit_update)
|
||||
script.on_event('on_rocket_launched',Sync.emit_update)
|
||||
Event.add('on_player_joined_game',Sync.emit_update)
|
||||
Event.add('on_pre_player_left_game',Sync.emit_update)
|
||||
Event.add('on_rocket_launched',Sync.emit_update)
|
||||
|
||||
function Sync:on_init()
|
||||
if loaded_modules['ExpGamingCore.Gui'] then verbose('ExpGamingCore.Gui is installed; Loading gui src') require(module_path..'/src/gui',{Sync=Sync,module_path=module_path}) end
|
||||
|
||||
@@ -96,11 +96,11 @@ Sync.info_gui = Gui.center{
|
||||
}.style.font='default-small'
|
||||
end}
|
||||
|
||||
script.on_event(defines.events.on_gui_click,function(event)
|
||||
Event.add(defines.events.on_gui_click,function(event)
|
||||
local element = event.element
|
||||
if element and element.valid and element.caption and element.caption == 'Press Ecs or E to close; this is only visible once!' then
|
||||
Gui.center.clear(event)
|
||||
end
|
||||
end)
|
||||
|
||||
script.on_event(defines.events.on_player_joined_game,function(event) Sync.info_gui(event) end)
|
||||
Event.add(defines.events.on_player_joined_game,function(event) Sync.info_gui(event) end)
|
||||
Reference in New Issue
Block a user