Wowpedia

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

READ MORE

Wowpedia
Register
No edit summary
mNo edit summary
(17 intermediate revisions by 12 users not shown)
Line 1: Line 1:
 
{{wowapi}} __NOTOC__
<center>'''GetContainerItemLink''' - ''Documentation by VelvetPaw''</center>
 
   
Returns the item link of the item located in bag# and slot#.
 
   
  +
<!-- Describe the purpose of the function, exhausting detail can be saved for a later section -->
ItemLink = GetContainerItemLink(bag,slot)
 
  +
Returns the [[ItemLink]] of the item located in [[bagID]] and slotID.
== Parameters ==
 
=== Arguments ===
 
   
  +
<!-- List return values and arguments as well as function name, follow Blizzard usage convention for args -->
:bag, slot
 
 
ItemLink = GetContainerItemLink(bagID, slotID)
   
:;bag : Numeric - The number of the bag. Valid bags are 0-4. 0 is the backpack.
 
   
 
== Parameters ==
:;slot : Numeric - The slot of the specified bag. Valid slots are 1 through BagSize. 1 is the left slot in the top row.
 
 
=== Arguments ===
  +
<!-- List each argument, together with its type -->
  +
:bagID, slotID
   
 
:;[[bagID]] : Numeric - The number of the bag. Valid bags are -2 - 11. 0 is the backpack.
=== Returns ===
 
 
:;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 ===
  +
<!-- 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).
+
:;[[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 ===
 
   
 
== Example ==
function UseContainerItemByName(SearchString)
 
  +
<!-- If it helps, include an example here, though it's not required if the usage is self-explanatory -->
for bag=0,4 do
 
 
function UseContainerItemByName(search)
for slot=1,GetContainerNumSlots(bag) do
 
 
for bag = 0,4 do
if (GetContainerItemLink(bag,slot)) then
 
 
for slot = 1,GetContainerNumSlots(bag) do
if (string.find(GetContainerItemLink(bag,slot), SearchString)) then
 
UseContainerItem(bag,slot)
+
local item = GetContainerItemLink(bag,slot)
end
+
if item and item:find(search) then
  +
UseContainerItem(bag,slot)
 
end
 
end
 
end
 
end
Line 32: Line 36:
 
end
 
end
   
  +
====Result====
  +
Searches through your bags and uses the first item found that contains the provided string in its name.
   
== Info ==
+
== Example ==
  +
<pre>/run link=GetContainerItemLink(0,1);printable=gsub(link, "\124", "\124\124");ChatFrame1:AddMessage("Here's the item code for item in Bag slot 0,1: \"" .. printable .. "\"");</pre>
=== for .. do ===
 
  +
  +
====Result====
 
Returns the [[ItemLink]] of the item located in bag 0, slot 1.
  +
  +
== Example ==
  +
<pre>/run _,_,itemLink=string.find(GetContainerItemLink(0,1),"(item:%d+)"); message(itemLink);</pre>
  +
  +
====Result====
  +
Returns the abbreviated [[ItemLink]] of the item located in bag 0, slot 1 (itemId only, useful for macros like "/use item:31339").
  +
  +
  +
====Info====
 
===== 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(bag) ===
+
===== GetContainerNumSlots(bagID) =====
   
:[[API GetContainerNumSlots|GetContainerNumSlots(index)]] - 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(bag,slot) ===
+
===== UseContainerItem(bagID,slotID) =====
   
:[[API UseContainerItem|UseContainerItem(bag,slot)]] - Uses an item located in bag# and slot#.
+
:[[API UseContainerItem|UseContainerItem(bagID,slot)]] - Uses an item located in [[bagID]] and slotID.
  +
:''Bad example. UseContainerItem() is protected these days. --[[User:Mikk|<span style="border-bottom: 1px dotted; cursor: help;" title="Mikk is a WoWWiki Admin">Mikk</span>]] <small>([[User talk:Mikk|T]])</small> 06:20, 26 May 2007 (UTC)''
   
=== 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]]
__NOTOC__
 
{{Template:WoW API}}
 
[[Category:API Inventory Functions|GetInventorySlotInfo]]
 

Revision as of 18:09, 28 March 2008


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(search)
  for bag = 0,4 do
    for slot = 1,GetContainerNumSlots(bag) do
      local item = GetContainerItemLink(bag,slot)
      if item and item:find(search) then
        UseContainerItem(bag,slot)
      end
    end
  end
end

Result

Searches through your bags and uses the first item found that contains the provided string in its name.

Example

/run link=GetContainerItemLink(0,1);printable=gsub(link, "\124", "\124\124");ChatFrame1:AddMessage("Here's the item code for item in Bag slot 0,1: \"" .. printable .. "\"");

Result

Returns the ItemLink of the item located in bag 0, slot 1.

Example

/run _,_,itemLink=string.find(GetContainerItemLink(0,1),"(item:%d+)"); message(itemLink);

Result

Returns the abbreviated ItemLink of the item located in bag 0, slot 1 (itemId only, useful for macros like "/use item:31339").


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.