WoW:API PickupSpell: Difference between revisions

using spellId currently seems to be the only method that actually works.
mNo edit summary
(using spellId currently seems to be the only method that actually works.)
Line 1: Line 1:
{{protectedcombatapi|2.0}} {{wowapi}}
{{protectedcombatapi|2.0}}  
{{wowapi}}
Puts the specified spell onto the mouse cursor.
Puts the specified spell onto the mouse cursor.
  PickupSpell("spellName" | spellId, bookType)
  PickupSpell("spellName" | spellId, bookType)


== Arguments ==
== Arguments ==
;spellName: String - the name of the spell.
;spellName
: String - the name of the spell.
or
or
;spellId : Numeric - the offset (position) of spell in spellbook. SpellId can change when you learn new spells.
;spellId
;bookType : String - Either BOOKTYPE_SPELL ("spell") or BOOKTYPE_PET ("pet").
: Numeric - the offset (position) of spell in spellbook. SpellId can change when you learn new spells.
;bookType
: String - Either BOOKTYPE_SPELL ("spell") or BOOKTYPE_PET ("pet").


== Notes ==
== Notes ==
Line 16: Line 20:
This example shows, how to put the most powerful version of a spell on cursor.
This example shows, how to put the most powerful version of a spell on cursor.
  PickupSpell("Moonfire")
  PickupSpell("Moonfire")
Or using the global spell id.
_, spellId = GetSpellBookItemInfo("Moonfire")
PickupSpell(spellId);


or
or
Line 26: Line 34:
       if (not name) then break; end
       if (not name) then break; end
       for s = offset + 1, offset + numSpells do
       for s = offset + 1, offset + numSpells do
         local spell, rank = GetSpellName(s, bookType);
         local spell, rank = GetSpellBookItemName(s, bookType);
         if (spell == spellName) then found = true; end
         if (spell == spellName) then found = true; end
         if (found and spell ~=spellName) then return s-1; end
         if (found and spell ~=spellName) then return s-1; end
Anonymous user