WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   GetSpellCooldown sometimes returning weird values (https://www.wowinterface.com/forums/showthread.php?t=58789)

MinguasBeef 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
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?

Ketho 06-10-21 07:46 AM

Sounds like https://github.com/Stanzilla/WoWUIBugs/issues/47

MinguasBeef 06-11-21 07:51 AM

Quote:

Originally Posted by Ketho (Post 339367)

Thanks so much!


All times are GMT -6. The time now is 10:44 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI