Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
Advertisement

Determines whether a spell can be used by the player character.

usable, noMana = IsUsableSpell(spell)
               = IsUsableSpell(index, bookType)

Arguments[]

spell
number|string - Spell ID or Name. When passing a name requires the spell to be in your Spellbook.
Spellbook args  
index
number - Spellbook slot index, ranging from 1 through the total number of spells across all tabs and pages.
bookType
string - BOOKTYPE_SPELL or BOOKTYPE_PET depending on if you wish to query the player or pet spellbook.
Internally the game only tests if this is equal to "pet" and treats any other string value as "spell".
Constant Value Description
BOOKTYPE_SPELL "spell" The General, Class, Specs and Professions tabs[1]
BOOKTYPE_PET "pet" The Pet tab

Returns[]

usable
boolean - True if the spell is usable, false otherwise. A spell might be un-usable for a variety of reasons, such as:
  • The player hasn't learned the spell
  • The player lacks required mana or reagents.
  • Reactive conditions haven't been met.
noMana
boolean - True if the spell can not be cast due to low mana, false otherwise.

Example[]

The following code snippet will check if the spell 'Healing Touch' can be cast:

 usable, nomana = IsUsableSpell("Curse of Elements");
 if (not usable) then
  if (not nomana) then
    message("The spell cannot be cast");
  else
    message("You do not have enough mana to cast the spell");
  end
 else
    message("The spell may be cast");
 end

The following code snippet will check if the 20th spell in the player's spellbook is usable:

 usable, nomana = IsUsableSpell(20, BOOKTYPE_SPELL); 
 print(GetSpellName(20, BOOKTYPE_SPELL) .. " is " .. (usable and "" or "not ") .. " usable.");
Advertisement