Quantcast
GetSpellCooldown sometimes returning weird values - WoWInterface
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
06-10-21, 07:16 AM   #1
MinguasBeef
A Cyclonian
AddOn Author - Click to view addons
Join Date: May 2019
Posts: 47
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
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?
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » GetSpellCooldown sometimes returning weird values

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off