From 6e19ea4f3eb8bf1dd2699f4fa95f50fe97106853 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sun, 1 Apr 2018 19:49:21 +0100 Subject: [PATCH] Added Sync.time --- ExpCore/sync.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ExpCore/sync.lua b/ExpCore/sync.lua index 1e55a505..9f375541 100644 --- a/ExpCore/sync.lua +++ b/ExpCore/sync.lua @@ -132,6 +132,8 @@ function Sync.info(set) if not global.exp_core.sync then global.exp_core.sync = { server_name='Factorio Server', reset_time='On Demand', + time='Day Mth 00 00:00:00 UTC Year', + time_set=0, last_update=0, time_period=18000, online=#game.connected_players, @@ -152,6 +154,21 @@ function Sync.info(set) end end +--- used to return the global time and set its value +-- @usage Sync.time('Sun Apr 1 18:44:30 UTC 2018') +-- @tparam[opt=nil] string the date time to be set +-- @return either true false if setting or the date time and tick off set +function Sync.time(set) + local info = Sync.info() + if not set then return info.time..'('..(game.tick-info.time_set)..')' + else + if not is_type(set,'string') then return false end + info.time = set + info.time_set = game.tick + return true + end +end + --- called to update values inside of the info -- @usage Sync.update() -- @return all of the new info