m (add note about GCD spell ID) |
mNo edit summary |
||
Line 2: | Line 2: | ||
Retrieves the cooldown data of the spell specified. |
Retrieves the cooldown data of the spell specified. |
||
− | start, duration, enabled = GetSpellCooldown(spellName or spellID or slotID, "bookType") |
+ | start, duration, enabled = GetSpellCooldown("spellName" or spellID or slotID, "bookType") |
==Arguments== |
==Arguments== |
||
− | :;spellName : String - name of the spell to |
+ | :;spellName : String - name of the spell to query. |
+ | or |
||
− | :;spellID : Number - ID of the spell |
+ | :;spellID : Number - ID of the spell to query. |
− | :;slotID : Number - Valid values are 1 through total number of spells in the spellbook on all pages and all tabs, ignoring empty slots. |
||
+ | or |
||
− | :;bookType : String - BOOKTYPE_SPELL or BOOKTYPE_PET depending on whether you wish to query the player or pet spellbook. |
||
+ | :;slotID : Number - index of a spell book slot to query, integers ascending from 1. |
||
+ | :;bookType : String - spell book category, e.g. <tt>BOOKTYPE_SPELL</tt> ("spell") or <tt>BOOKTYPE_PET</tt> ("pet"). |
||
==Returns== |
==Returns== |
||
− | + | ;startTime : Number - The time when the cooldown started (as returned by [[API GetTime|GetTime()]]); zero if no cooldown; current time if (enabled == 0). |
|
− | + | ;duration : Number - Cooldown duration in seconds, 0 if spell is ready to be cast. |
|
− | + | ;enabled : Number - 0 if the spell is active (Stealth, Shadowmeld, Presence of Mind, etc) and the cooldown will begin as soon as the spell is used/cancelled; 1 otherwise. |
|
==Example== |
==Example== |
||
+ | The following snippet checks the state of [[Presence of Mind]] cooldown. On English clients, you could also use <tt>"Presence of Mind"</tt> in place of <tt>12043</tt>, which is the spell's ID. |
||
− | + | local start, duration, enabled = GetSpellCooldown(12043) |
|
if enabled == 0 then |
if enabled == 0 then |
||
− | + | print("Presence of Mind is currently active, use it and wait " .. duration .. " seconds for the next one.") |
|
elseif ( start > 0 and duration > 0) then |
elseif ( start > 0 and duration > 0) then |
||
− | + | local cdLeft = start + duration - GetTime() |
|
+ | print("Presence of Mind is cooling down, wait " .. cdLeft .. " seconds for the next one.") |
||
else |
else |
||
− | + | print("Presence of Mind is ready.") |
|
end |
end |
||
− | |||
− | ===Result=== |
||
− | Checks status of the [[Presence of Mind]] cooldown and outputs the appropriate message to the default chat frame. |
||
− | |||
− | ==Example== |
||
− | local name = GetSpellInfo(28370); |
||
− | local start, duration, enabled = GetSpellCooldown(name); |
||
− | etc... |
||
− | |||
− | Example of using SpellIDs to retrieve cooldown info |
||
− | |||
− | |||
− | ==Example== |
||
− | local start, duration, enabled = GetSpellCooldown(48505); |
||
− | |||
− | ===Result=== |
||
− | returns 0, 0, 1 if the spell 'Starfall' is not on Cooldown |
||
− | otherwise it returns GetTime(), 90, 1 |
||
− | |||
==Notes== |
==Notes== |
||
− | * |
+ | * To check the [[Global Cooldown]], you can use the spell ID <tt>61304</tt>. This is a dummy spell specifically for the GCD. |
− | *The enabled return value allows addons to easily check if the player has used a buff-providing spell (such as Presence of Mind or Nature's Swiftness) without searching through the player's buffs. |
+ | * The enabled return value allows addons to easily check if the player has used a buff-providing spell (such as Presence of Mind or Nature's Swiftness) without searching through the player's buffs. |
− | *Values returned by this function are not updated immediately when UNIT_SPELLCAST_SUCCEEDED event is raised. |
+ | * Values returned by this function are not updated immediately when {{api|t=e|UNIT_SPELLCAST_SUCCEEDED}} event is raised. |
Revision as of 17:54, 16 April 2014
Automated updating of API pages at this location, to reflect patch changes, has ceased from 10.1.7 onwards. |
Retrieves the cooldown data of the spell specified.
start, duration, enabled = GetSpellCooldown("spellName" or spellID or slotID, "bookType")
Arguments
- spellName
- String - name of the spell to query.
or
- spellID
- Number - ID of the spell to query.
or
- slotID
- Number - index of a spell book slot to query, integers ascending from 1.
- bookType
- String - spell book category, e.g. BOOKTYPE_SPELL ("spell") or BOOKTYPE_PET ("pet").
Returns
- startTime
- Number - The time when the cooldown started (as returned by GetTime()); zero if no cooldown; current time if (enabled == 0).
- duration
- Number - Cooldown duration in seconds, 0 if spell is ready to be cast.
- enabled
- Number - 0 if the spell is active (Stealth, Shadowmeld, Presence of Mind, etc) and the cooldown will begin as soon as the spell is used/cancelled; 1 otherwise.
Example
The following snippet checks the state of [Presence of Mind] cooldown. On English clients, you could also use "Presence of Mind" in place of 12043, which is the spell's ID.
local start, duration, enabled = GetSpellCooldown(12043) if enabled == 0 then print("Presence of Mind is currently active, use it and wait " .. duration .. " seconds for the next one.") elseif ( start > 0 and duration > 0) then local cdLeft = start + duration - GetTime() print("Presence of Mind is cooling down, wait " .. cdLeft .. " seconds for the next one.") else print("Presence of Mind is ready.") end
Notes
- To check the Global Cooldown, you can use the spell ID 61304. This is a dummy spell specifically for the GCD.
- The enabled return value allows addons to easily check if the player has used a buff-providing spell (such as Presence of Mind or Nature's Swiftness) without searching through the player's buffs.
- Values returned by this function are not updated immediately when UNIT_SPELLCAST_SUCCEEDED event is raised.