hello
I have a problem with a calculation, I'm using
to get remaining seconds after i get a storagevalue.
So, my problem here is following: i want to use this like 'There's still ' .. timeString(time) .. ' 'left until you can use this again.'
my calculation is: local time = os.time() - player:getStorageValue(14092) but it don't give me right calculation. I do this to get some time between usage of item like player:setStorageValue(14092, os.time() + 100 but it don't say this after, just random like 8 h left...
help please )
I have a problem with a calculation, I'm using
Code:
function timeString(timeDiff)
local dateFormat = {
{"day", timeDiff / 60 / 60 / 24},
{"hour", timeDiff / 60 / 60 % 24},
{"minute", timeDiff / 60 % 60},
{"second", timeDiff % 60}
}
local out = {}
for k, t in ipairs(dateFormat) do
local v = math.floor(t[2])
if(v > 0) then
table.insert(out, (k < #dateFormat and (#out > 0 and ', ' or '') or ' and ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or ''))
end
end
local ret = table.concat(out)
if ret:len() < 16 and ret:find("second") then
local a, b = ret:find(" and ")
ret = ret:sub(b+1)
end
return ret
end
So, my problem here is following: i want to use this like 'There's still ' .. timeString(time) .. ' 'left until you can use this again.'
my calculation is: local time = os.time() - player:getStorageValue(14092) but it don't give me right calculation. I do this to get some time between usage of item like player:setStorageValue(14092, os.time() + 100 but it don't say this after, just random like 8 h left...
help please )