API GetSpellCooldown
Retrieves the cooldown data of the spell specified.
local start, duration = GetSpellCooldown(spellID, "bookType");
Arguments
- (Number spellID)
- SpellID
- The ID of the spell to retrieve cooldown data for
- (string bookType)
- BookType
- BOOKTYPE_SPELL or BOOKTYPE_PET depending on whether you wish to query the player or pet spellbook.
Returns
- (Number startTime, Number duration, Number enable)
- StartTime
- The time when the cooldown started (as returned by GetTime()) or zero if no cooldown
- Duration
- The number of seconds the cooldown will last, or zero if no cooldown
- Enable
- Appears to return 1 no matter what.
Example 1
Retrieves data on the cooldown of a specific spell within your spellbook.
/run local start, duration = GetSpellCooldown(spellID, BOOKTYPE_SPELL);if ( start > 0 and duration > 0) then Print('Please wait ' .. duration - ( GetTime() - start) .. ' seconds before using this spell.');else Print('Spell is ready.');end
- Result
Retrieves data. Does not actually change anything.
"For the Nature's Swiftness spell and possibly other spells that don't start their cooldown timer before they are used up the values retrieved by GetSpellCooldown change over time.
The startTime returned is the current time (that this function was called), not the time the spell was cast. The duration is 0.001 not the spell's normal cooldown.In this way we can use GetSpellCooldown to see if this type of spell is active on the player without having to look at buffs and debuffs."
Example 2
Uses getspellcooldown to track if SPELL ONE is ready. When the spell is ready it is used, if it is not ready then SPELL TWO is used
/run local c,s=CastSpellByName,"SPELL ONE";local i=nil;for j=1,180 do local n=GetSpellName(j,BOOKTYPE_SPELL);if n and strfind(n,s) then i=j;break;end end if i then if GetSpellCooldown(i,BOOKTYPE_SPELL)<1 then c(s)else c("SPELL TWO")end end