Huge code clean up

This commit is contained in:
Cooldude2606
2023-12-22 19:45:34 +00:00
parent 78215f9932
commit 855ae23ee5
2 changed files with 109 additions and 642 deletions

View File

@@ -56,6 +56,16 @@ local function format_minutes(value)
})
end
--- Used to format time into a clock
local function format_clock(value)
return format_time(value*3600, {
hours=true,
minutes=true,
seconds=false,
time=true
})
end
--- Add MapsPlayed if it is enabled
if config.MapsPlayed then
Statistics:combine('MapsPlayed')
@@ -68,8 +78,8 @@ end
--- Add Playtime and AfkTime if it is enabled
if config.Playtime or config.AfkTime then
local playtime, afk_time
if config.Playtime then playtime = Statistics:combine('Playtime') playtime:set_metadata{stringify=format_minutes} end
if config.AfkTime then afk_time = Statistics:combine('AfkTime') afk_time:set_metadata{stringify=format_minutes} end
if config.Playtime then playtime = Statistics:combine('Playtime') playtime:set_metadata{stringify=format_minutes, stringify_short=format_clock} end
if config.AfkTime then afk_time = Statistics:combine('AfkTime') afk_time:set_metadata{stringify=format_minutes, stringify_short=format_clock} end
Event.on_nth_tick(3600, function()
if game.tick == 0 then return end
for _, player in pairs(game.connected_players) do