Sometimes GetSpellCooldown works exactly like i'd expect. Other times it seems to return strange values.
I was making a basic script to just print out my cooldowns for my tailoring cloths.
Here was the function I made
Code:
function PrintCooldown(spellName, spellId)
local cd, duration = GetSpellCooldown(spellId)
if (cd == 0) then
print("|c0088FF88" .. spellName .." cooldown is ready!|r")
else
local secondsRemaining = math.floor((cd+duration) - GetTime())
local minutesRemaining = math.floor(secondsRemaining / 60)
local hoursRemaining = math.floor(minutesRemaining / 60)
local daysRemaining = math.floor(hoursRemaining / 24)
secondsRemaining = math.floor(secondsRemaining - minutesRemaining * 60)
minutesRemaining = math.floor(minutesRemaining - hoursRemaining * 60)
hoursRemaining = math.floor(hoursRemaining - daysRemaining * 24)
local msg = "|c00FF8888" .. spellName .." cooldown: "
if (daysRemaining > 0) then
msg = msg .. daysRemaining .. "d "
end
if (hoursRemaining > 0) then
msg = msg .. hoursRemaining .. "h "
end
if (minutesRemaining > 0) then
msg = msg .. minutesRemaining .. "m "
end
if (secondsRemaining > 0) then
msg = msg .. secondsRemaining .. "s "
end
msg = msg .. "|r"
print(msg)
end
end
It usually works, but sometimes i'll notice strange values. Right now, I am getting a cooldown of 51 days 16hrs 24m 47s when it should be 1d 23h.
If I do a print(GetSpellCooldown(36686)) to get the info for the spell to craft shadowcloth, I get back the following.
42525454.021 331200 1 1
If I do print(GetTime()) i'm getting the following.
118589.087
I was under the impression that I should be able to get the time that the cooldown started with GetSpellCooldown(), but as you can see sometimes it's giving me something that i'm not sure how to use.
Any ideas? Could it be related to overflow? If so, at what number does overflow occur in wow lua?