WoW:API PickupSpell: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
mNo edit summary
m (Move page script moved page API PickupSpell to API PickupSpell without leaving a redirect)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{protectedcombatapi|2.0}}
{{wowapi}}
Puts the specified spell onto the mouse cursor.
  PickupSpell("spellName" | spellId, bookType)
  PickupSpell("spellName" | spellId, bookType)


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


<!-- List each return value, together with its type -->
== Notes ==
:Nothing.
* This function will put a spell on mouse cursor. The spell is defined by spellbook and it's position in the spellbook.
 
* The cursor needs to be clear in order to use this function.
----
;''Details''
 
:This function will put a spell on mouse cursor. The spell is defined by spellbook and it's position in the spellbook.
:The cursor needs to be clear in order to use this function.
 
----
;''Example''


==  Example ==
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(spellName)
Or using the global spell id.
_, spellId = GetSpellBookItemInfo("Moonfire")
PickupSpell(spellId);


or
or
Line 39: 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
Line 51: Line 46:
   local id = findSpell(spellName, bookType);
   local id = findSpell(spellName, bookType);
   PickupSpell(id, bookType);
   PickupSpell(id, bookType);
----
see also [[API PickupAction | PickupAction()]], [[API PickupPetAction | PickupPetAction()]], [[API PickupBagFromSlot | PickupBagFromSlot()]], [[API PickupContainerItem | PickupContainerItem()]], [[API PickupInventoryItem | PickupInventoryItem()]], [[API PickupItem | PickupItem()]], [[API PickupMacro | PickupMacro()]], [[API PickupMerchantItem | PickupMerchantItem()]],[[API PickupPetAction | PickupPetAction()]], [[API PickupPlayerMoney | PickupPlayerMoney()]], [[API PickupStablePet | PickupStablePet()]], [[API PickupTradeMoney | PickupTradeMoney()]], [[API ClearCursor | ClearCursor()]]


----
== See Also ==
{{wowapi}}
* {{api|PickupAction}}, {{api|PickupPetAction}}, {{api|PickupBagFromSlot}}, {{api|PickupContainerItem}}, {{api|PickupInventoryItem}}, {{api|PickupItem}}, {{api|PickupMacro}}, {{api|PickupMerchantItem}}, {{api|PickupPlayerMoney}}, {{api|PickupStablePet}}, {{api|PickupTradeMoney}}
* {{api|ClearCursor}}

Latest revision as of 04:47, 15 August 2023

WoW API < PickupSpell

Puts the specified spell onto the mouse cursor.

PickupSpell("spellName" | spellId, bookType)

Arguments

spellName
String - the name of the spell.

or

spellId
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

  • This function will put a spell on mouse cursor. The spell is defined by spellbook and it's position in the spellbook.
  • The cursor needs to be clear in order to use this function.

Example

This example shows, how to put the most powerful version of a spell on cursor.

PickupSpell("Moonfire")

Or using the global spell id.

_, spellId = GetSpellBookItemInfo("Moonfire")
PickupSpell(spellId);

or

 function findSpell(spellName, bookType)
   local i, s;
   local found = false;
   for i = 1, MAX_SKILLLINE_TABS do
     local name, texture, offset, numSpells = GetSpellTabInfo(i);
     if (not name) then break; end
     for s = offset + 1, offset + numSpells do
       local	spell, rank = GetSpellBookItemName(s, bookType);
       if (spell == spellName) then found = true; end
       if (found and spell ~=spellName) then return s-1; end
     end
   end
   if (found) then return s; end
   return nil;
 end
 local bookType = BOOKTYPE_SPELL;
 local id = findSpell(spellName, bookType);
 PickupSpell(id, bookType);

See Also