So I have this timer for my speed run type game it has minutes seconds and milliseconds.
Right now this happens:
Here is the script:
local ConvertTime = {}
ConvertTime.Convert = function(Number)
local min = math.floor(Number/60)
local sec = math.floor(Number)-60*min
local milisec = math.floor((Number-sec-min*60)*1000+0.5)
if min < 1 then
min = ""
else
min = min..":"
end
if sec < 10 then
sec = "0"..sec
end
if milisec < 100 and milisec >= 10 then
milisec = "0"..milisec
elseif milisec < 10 then
milisec = "00"..milisec
end
local output = min..sec.."."..milisec
return output
end
return ConvertTime
Sorry, in hindsight I wasn’t looking closely at how you were formatting your numbers. You could try:
ConvertTime.Convert = function(Number)
local min = math.floor(Number/60)
local sec = math.floor(Number)-60*min
local milisec = string.sub( tostring(math.floor((Number-sec-min*60)*1000+0.5)) , 1, 1)
min = (min < 1) and "" or tostring(min) .. ':'
local output = string.format("%s%02d.%s", min, sec, milisec)
return output
end
I don’t like how milliseconds is handled in this but I can’t think of a better way to do it right now.