From fb75501b6f40b6047a4ae2fdd08c8581b3eed274 Mon Sep 17 00:00:00 2001 From: Toledin Date: Thu, 1 Feb 2018 16:02:31 -0500 Subject: [PATCH] improved time --- server_api.lua | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/server_api.lua b/server_api.lua index e32db801..b6fe8b6a 100644 --- a/server_api.lua +++ b/server_api.lua @@ -7,5 +7,27 @@ function bot_command_players(filename) end function bot_command_time(filename) - game.write_file(filename, string.format("Time since server start (%d):"),#math.floor(game.tick / 60), false,0) + local s = math.floor(game.tick/60) + local m = math.floor(s/60) + local h = math.floor(m/60) + local d = math.floor(h/24) + + s = s % 60 + m = m % 60 + h = h % 24 + if d == 0 then + d = "" + if h == 0 then + h = "" + if m == 0 then + m = "" + end + end + else + d = string.format("%s days ", d) + end + + if m ~= "" then m = string.format("%s minutes ", m) end + if h ~= "" then h = string.format("%s hours ", h) end + game.write_file(filename,string.format("%s%s%s%s seconds", d, h, m, s), false,0) end