Wowpedia

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

READ MORE

Wowpedia
Register
No edit summary
Line 1: Line 1:
  +
{{wowapi}} __NOTOC__
<center>'''GetContainerItemLink''' - ''Documentation by VelvetPaw''</center>
 
   
  +
  +
<!-- Describe the purpose of the function, exhausting detail can be saved for a later section -->
 
Returns the item link of the item located in bag# and slot#.
 
Returns the item link of the item located in bag# and slot#.
   
  +
<!-- List return values and arguments as well as function name, follow Blizzard usage convention for args -->
ItemLink = GetContainerItemLink(bag,slot)
+
ItemLink = GetContainerItemLink(bag, slot)
  +
  +
 
== Parameters ==
 
== Parameters ==
 
=== Arguments ===
 
=== Arguments ===
  +
<!-- List each argument, together with its type -->
 
 
:bagID, slot
 
:bagID, slot
   
 
:;[[API TYPE bagID|bagID]] : Numeric - The number of the bag. Valid bags are 0-4. 0 is the backpack.
 
:;[[API TYPE bagID|bagID]] : Numeric - The number of the bag. Valid bags are 0-4. 0 is the backpack.
 
 
:;slot : Numeric - The slot of the specified bag. Valid slots are 1 through BagSize. 1 is the left slot in the top row.
 
:;slot : Numeric - The slot of the specified bag. Valid slots are 1 through BagSize. 1 is the left slot in the top row.
   
 
=== Returns ===
 
=== Returns ===
  +
<!-- List each return value, together with its type -->
 
 
:ItemLink
 
: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|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'''
 
:;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|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'''
   
=== Example ===
+
== Example ==
  +
<!-- If it helps, include an example here, though it's not required if the usage is self-explanatory -->
 
 
function UseContainerItemByName(SearchString)
 
function UseContainerItemByName(SearchString)
 
for bag=0,4 do
 
for bag=0,4 do
Line 33: Line 37:
 
end
 
end
   
  +
====Result====
  +
Searches through your bags and uses the first item found that contains the provided string in its name.
   
== Info ==
+
====Info====
=== for .. do ===
+
===== for .. do =====
   
 
:Look for the 'for .. do' block at the [http://www.lua.org/manual/5.0/ Reference Manual].
 
:Look for the 'for .. do' block at the [http://www.lua.org/manual/5.0/ Reference Manual].
   
=== GetContainerNumSlots(bagID) ===
+
===== GetContainerNumSlots(bagID) =====
   
 
:[[API GetContainerNumSlots|GetContainerNumSlots(bagID)]] - Gives you the number of slots available in the bag specified by the index.
 
:[[API GetContainerNumSlots|GetContainerNumSlots(bagID)]] - Gives you the number of slots available in the bag specified by the index.
   
=== UseContainerItem(bagID,slot) ===
+
===== UseContainerItem(bagID,slot) =====
   
 
:[[API UseContainerItem|UseContainerItem(bagID,slot)]] - Uses an item located in bag# and slot#.
 
:[[API UseContainerItem|UseContainerItem(bagID,slot)]] - Uses an item located in bag# and slot#.
   
=== string.find(string,pattern{,init{,plain}}) ===
+
===== string.find(string,pattern{,init{,plain}}) =====
   
 
:[[API strfind|strfind(string,pattern{,init{,plain}})]] - Look for match of pattern in string, optionally from specific location or using plain substring.
 
:[[API strfind|strfind(string,pattern{,init{,plain}})]] - Look for match of pattern in string, optionally from specific location or using plain substring.
   
  +
[[Category:World of Warcraft API]]
----
 
{{WoW API}}
 

Revision as of 19:46, 9 September 2006


Returns the item link of the item located in bag# and slot#.

ItemLink = GetContainerItemLink(bag, slot)


Parameters

Arguments

bagID, slot
bagID
Numeric - The number of the bag. Valid bags are 0-4. 0 is the backpack.
slot
Numeric - The slot of the specified bag. Valid slots 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|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

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,slot)
UseContainerItem(bagID,slot) - Uses an item located in bag# and slot#.
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.