WoW:API GetContainerItemLink: Difference between revisions
Jump to navigation
Jump to search
(Corrected valid range of the parameter bagID.) |
|||
Line 14: | Line 14: | ||
:bagID, slotID | :bagID, slotID | ||
:;[[bagID]] : Numeric - The number of the bag. Valid bags are | :;[[bagID]] : Numeric - The number of the bag. Valid bags are -2 - 11. 0 is the backpack. | ||
:;slotID : Numeric - The slot of the specified bag. Valid slotID's are 1 through BagSize. 1 is the left slot in the top row. | :;slotID : Numeric - The slot of the specified bag. Valid slotID's are 1 through BagSize. 1 is the left slot in the top row. | ||
Revision as of 05:11, 25 November 2007
← WoW API < GetContainerItemLink
Returns the ItemLink of the item located in bagID and slotID.
ItemLink = GetContainerItemLink(bagID, slotID)
Parameters
Arguments
- bagID, slotID
- bagID
- Numeric - The number of the bag. Valid bags are -2 - 11. 0 is the backpack.
- slotID
- Numeric - The slot of the specified bag. Valid slotID's are 1 through BagSize. 1 is the left slot in the top row.
Returns
- ItemLink
- ItemLink
- Returns the ItemLink (The item link is the link when you shift-click an item while the chat edit box is visible). Returns nil if the slot of the specified bag is empty. Example link returned: |Hitem:6948:0:0:0:0:0:0:0|h[Hearthstone]|h . To use this link in other functions that require an ItemLink, you have to strip out the extra chat link information. Ex: item:6948:0:0:0:0:0:0:0
Example
function UseContainerItemByName(SearchString) for bag=0,4 do for slot=1,GetContainerNumSlots(bag) do if (GetContainerItemLink(bag,slot)) then if (string.find(GetContainerItemLink(bag,slot), SearchString)) then UseContainerItem(bag,slot) end end end end end
Result
Searches through your bags and uses the first item found that contains the provided string in its name.
Info
for .. do
- Look for the 'for .. do' block at the Reference Manual.
GetContainerNumSlots(bagID)
- GetContainerNumSlots(bagID) - Gives you the number of slots available in the bag specified by the index.
UseContainerItem(bagID,slotID)
- UseContainerItem(bagID,slot) - Uses an item located in bagID and slotID.
- Bad example. UseContainerItem() is protected these days. --Mikk (T) 06:20, 26 May 2007 (UTC)
string.find(string,pattern{,init{,plain}})
- strfind(string,pattern{,init{,plain}}) - Look for match of pattern in string, optionally from specific location or using plain substring.