в вашем коде мало ошибок, if(minNeeded == 1){
- синтаксическая ошибка, while true do
никогда не сломается.Вот простой конвертер,
function prettyTime(sec)
local sec = tonumber(sec)
if sec <= 0 then
return "00.00.00";
else
h = tonumber(string.format("%02.f", math.floor(sec/3600)))
m = tonumber(string.format("%02.f", math.floor(sec/60 - (h*60))))
s = tonumber(string.format("%02.f", math.floor(sec - h*3600 - m*60)))
-- return h.."."..m.."."..s
end
local res = ''
if h == 1 then
res = res ..h .. ' hour, '
elseif h > 1 then
res = res ..h .. ' hours, '
end
if m <= 1 then
res = res ..m .. ' minute, '
elseif m > 1 then
res = res ..m .. ' minute, '
end
if s <= 1 then
res = res ..s .. ' second, '
elseif s > 1 then
res = res ..s .. ' seconds '
end
return res
end
print(prettyTime(3670)) -- 1 hour, 1 minute, 10 seconds