Added Tick To Display Format

This commit is contained in:
Cooldude2606
2017-07-14 17:46:42 +01:00
parent 97d3fd0596
commit a2e2a7a27d
3 changed files with 13 additions and 7 deletions

View File

@@ -18,15 +18,21 @@ local credits = {{
}}
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
--Please Only Edit Below This Line-----------------------------------------------------------
--this converts ticks to 12H 34M format or 8.97M when less than 10
function tick_to_display_format(tick)
if tick_to_min(tick) < 10 then
return string.format('%.2f M',tick/(3600*game.speed))
else
return string.format('%d H %d M',tick_to_hour(tick),tick_to_min(tick)-60*tick_to_hour(tick))
end
end
--this will convert ticks into hours based on game speed
function tick_to_hour (tick)
local hour = tostring(math.floor(tick/(216000*game.speed)))
return hour
return math.floor(tick/(216000*game.speed))
end
--this will convert ticks into minutes based on game speed
function tick_to_min (tick)
local minutes = math.floor(tick/(3600*game.speed))
return minutes
return math.floor(tick/(3600*game.speed))
end
--i stole this from somewhere a long time ago but this and the other two functions convert a table into a string
function table.val_to_str ( v )