Added Sync.time

This commit is contained in:
Cooldude2606
2018-04-01 19:49:21 +01:00
parent 235a32298c
commit 6e19ea4f3e

View File

@@ -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