- Lua/XML Help
||06-10-21 07:16 AM
GetSpellCooldown sometimes returning weird values
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
function PrintCooldown(spellName, spellId)
local cd, duration = GetSpellCooldown(spellId)
if (cd == 0) then
print("|c0088FF88" .. spellName .." cooldown is ready!|r")
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 "
if (hoursRemaining > 0) then
msg = msg .. hoursRemaining .. "h "
if (minutesRemaining > 0) then
msg = msg .. minutesRemaining .. "m "
if (secondsRemaining > 0) then
msg = msg .. secondsRemaining .. "s "
msg = msg .. "|r"
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.
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?
||06-11-21 07:51 AM
|All times are GMT -6. The time now is 04:39 AM.
vBulletin © 2021, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI