mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 19:45:22 +09:00
Added Sync.tick_format
This commit is contained in:
@@ -18,6 +18,12 @@ function Sync.set_ranks(...)
|
||||
Ranking._base_preset(...)
|
||||
end
|
||||
|
||||
--- Used to standidise the tick format for any sync info
|
||||
-- @usage Sync.tick_format(60) -- return {60,'1.00M'}
|
||||
function Sync.tick_format(tick)
|
||||
return {tick,tick_to_display_format(18000)}
|
||||
end
|
||||
|
||||
--- Prints to chat as if it were a player
|
||||
-- @usage Sync.print('Test','Cooldude2606')
|
||||
-- @param player_message the message to be printed in chat
|
||||
@@ -146,7 +152,7 @@ function Sync.count_player_times()
|
||||
if not game then return {'Offline'} end
|
||||
local _players = {}
|
||||
for index,player in pairs(game.players) do
|
||||
_players[player.name] = {player.online_time,tick_to_display_format(player.online_time)}
|
||||
_players[player.name] = Sync.tick_format(player.online_time)
|
||||
end
|
||||
return _players
|
||||
end
|
||||
@@ -162,9 +168,9 @@ function Sync.info(set)
|
||||
server_description='A factorio server for everyone',
|
||||
reset_time='On Demand',
|
||||
time='Day Mth 00 00:00:00 UTC Year',
|
||||
time_set={0,tick_to_display_format(0)},
|
||||
last_update={0,tick_to_display_format(0)},
|
||||
time_period={18000,tick_to_display_format(18000)},
|
||||
time_set=Sync.tick_format(0),
|
||||
last_update=Sync.tick_format(0),
|
||||
time_period=Sync.tick_format(18000),
|
||||
players={
|
||||
online=Sync.count_players(true),
|
||||
n_online=#game.connected_players,
|
||||
@@ -227,6 +233,10 @@ function Sync.update()
|
||||
return info
|
||||
end
|
||||
|
||||
--- Adds a callback to be called when the info is updated
|
||||
-- @usage Sync.add_update('players',function() return #game.players end)
|
||||
-- @tparam key string the key that the value will be stored in
|
||||
-- @tparam callback function the function which will return this value
|
||||
function Sync.add_update(key,callback)
|
||||
if game then return end
|
||||
if not is_type(callback,'function') then return end
|
||||
|
||||
Reference in New Issue
Block a user