From 55937c343db0429e7228358f7311660fe73f0020 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sat, 21 Jul 2018 16:36:07 +0100 Subject: [PATCH 1/4] Added afk times to sync --- ExpCore/sync.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ExpCore/sync.lua b/ExpCore/sync.lua index dd3a1840..34218828 100644 --- a/ExpCore/sync.lua +++ b/ExpCore/sync.lua @@ -113,14 +113,14 @@ end -- @usage Sync.count_afk() -- @tparam[opt=7200] int time in ticks that a player is called afk -- @treturn int the number of afk players -function Sync.count_afk(time) +function Sync.count_afk_times(time) if not game then return 0 end local time = time or 7200 - local _count = 0 + local rtn = {} for _,player in pairs(game.connected_players) do - if player.afk_time > time then _count=_count+1 end + if player.afk_time > time then rtn[player.name] = player.afk_time end end - return _count + return rtn end --- used to get the number of players in each rank and currently online @@ -175,6 +175,7 @@ function Sync.info(set) server_description='A factorio server for everyone', reset_time='On Demand', time='Day Mth 00 00:00:00 UTC Year', + game_speed=game.speed, time_set=Sync.tick_format(0), last_update=Sync.tick_format(0), time_period=Sync.tick_format(18000), @@ -184,7 +185,7 @@ function Sync.info(set) all=Sync.count_players(), n_all=#game.players, admins_online=Sync.count_admins(), - afk_players=Sync.count_afk(), + afk_players=Sync.count_afk_times(), times=Sync.count_player_times() }, ranks=Sync.count_ranks(), @@ -225,6 +226,7 @@ function Sync.update() info.time_period[2] = tick_to_display_format(info.time_period[1]) info.last_update[1] = game.tick info.last_update[2] = tick_to_display_format(game.tick) + info.game_speed=game.speed, info.players={ online=Sync.count_players(true), n_online=#game.connected_players, From ad746de68c21bad0077a6dcb0ca9bbb662965637 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sat, 21 Jul 2018 16:39:24 +0100 Subject: [PATCH 2/4] Forgot tp update function name --- ExpCore/sync.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExpCore/sync.lua b/ExpCore/sync.lua index 34218828..479d6e7c 100644 --- a/ExpCore/sync.lua +++ b/ExpCore/sync.lua @@ -233,7 +233,7 @@ function Sync.update() all=Sync.count_players(), n_all=#game.players, admins_online=Sync.count_admins(), - afk_players=Sync.count_afk(), + afk_players=Sync.count_afk_times(), times=Sync.count_player_times() } info.ranks = Sync.count_ranks() From e95c6c039eb09cd13f3780129cd4300cfef02aea Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sat, 21 Jul 2018 17:06:34 +0100 Subject: [PATCH 3/4] Forgot to maintain tick formating --- ExpCore/sync.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExpCore/sync.lua b/ExpCore/sync.lua index 479d6e7c..3d1085b2 100644 --- a/ExpCore/sync.lua +++ b/ExpCore/sync.lua @@ -118,7 +118,7 @@ function Sync.count_afk_times(time) local time = time or 7200 local rtn = {} for _,player in pairs(game.connected_players) do - if player.afk_time > time then rtn[player.name] = player.afk_time end + if player.afk_time > time then rtn[player.name] = Sync.tick_format(player.afk_time) end end return rtn end From 32ba9f2ddad07b8d9d868eb37bb81f1006ac3b5f Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sun, 22 Jul 2018 18:15:59 +0100 Subject: [PATCH 4/4] Fixed Sync Error --- ExpCore/sync.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExpCore/sync.lua b/ExpCore/sync.lua index 3d1085b2..31df4607 100644 --- a/ExpCore/sync.lua +++ b/ExpCore/sync.lua @@ -226,7 +226,7 @@ function Sync.update() info.time_period[2] = tick_to_display_format(info.time_period[1]) info.last_update[1] = game.tick info.last_update[2] = tick_to_display_format(game.tick) - info.game_speed=game.speed, + info.game_speed=game.speed info.players={ online=Sync.count_players(true), n_online=#game.connected_players,