Wikia

WoWWiki

Changes: API IsUsableSpell

Edit

Back to page

m (Example)
 
Line 3: Line 3:
 
Determines whether a spell can be used by the player character.
 
Determines whether a spell can be used by the player character.
   
usable, nomana = IsUsableSpell("spellName" or spellIndex[, "bookType"]);
+
usable, nomana = IsUsableSpell("spellName" or spellID or spellIndex[, "bookType"]);
   
 
==Arguments==
 
==Arguments==
 
;spellName : String: name of the spell to check.
 
;spellName : String: name of the spell to check.
 
;spellIndex : Number: index of a spell in the player's (or pet's) spellbook.
 
;spellIndex : Number: index of a spell in the player's (or pet's) spellbook.
  +
;spellID : Number: SpellID of a spell to check.
 
;bookType: String: does the spellIndex refer to the player's spellbook (BOOKTYPE_SPELL constant, default), or the pet's spellbook (BOOKTYPE_PET constant).
 
;bookType: String: does the spellIndex refer to the player's spellbook (BOOKTYPE_SPELL constant, default), or the pet's spellbook (BOOKTYPE_PET constant).
   

Latest revision as of 02:19, October 14, 2010

WoW API < IsUsableSpell

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

usable, nomana = IsUsableSpell("spellName" or spellID or spellIndex[, "bookType"]);

ArgumentsEdit

spellName 
String: name of the spell to check.
spellIndex 
Number: index of a spell in the player's (or pet's) spellbook.
spellID 
Number: SpellID of a spell to check.
bookType
String: does the spellIndex refer to the player's spellbook (BOOKTYPE_SPELL constant, default), or the pet's spellbook (BOOKTYPE_PET constant).

ReturnsEdit

usable 
Boolean : 1 (true) if the spell is usable, nil otherwise. A spell is not usable if any of the following conditions apply:
  • The player hasn't learned the spell
  • The player lacks required mana or reagents.
  • Reactive conditions haven't been met.
nomana 
Boolean : 1 (true) if the spell can not be cast due to low mana, nil otherwise.

ExampleEdit

 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
 usable, nomana = IsUsableSpell(20, BOOKTYPE_SPELL); 
 print(GetSpellName(20, BOOKTYPE_SPELL) .. " is " .. (usable and "" or "not ") .. " usable.");

Around Wikia's network

Random Wiki