m
Move page script moved page API GetContainerItemLink to WoW:API GetContainerItemLink without leaving a redirect
(Homogenized variable names and added links for ItemLink and BagID) |
m (Move page script moved page API GetContainerItemLink to WoW:API GetContainerItemLink without leaving a redirect) |
||
| (5 intermediate revisions by 5 users not shown) | |||
| Line 14: | Line 14: | ||
:bagID, slotID | :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. | :;slotID : Numeric - The slot of the specified bag. Valid slotID's are 1 through BagSize. 1 is the left slot in the top row. | ||
| Line 21: | Line 21: | ||
: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: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 == | ||
<!-- If it helps, include an example here, though it's not required if the usage is self-explanatory --> | <!-- If it helps, include an example here, though it's not required if the usage is self-explanatory --> | ||
function UseContainerItemByName( | function UseContainerItemByName(search) | ||
for bag=0,4 do | for bag = 0,4 do | ||
for slot=1,GetContainerNumSlots(bag) 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 | ||
| Line 39: | Line 38: | ||
====Result==== | ====Result==== | ||
Searches through your bags and uses the first item found that contains the provided string in its name. | Searches through your bags and uses the first item found that contains the provided string in its name. | ||
== 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> | |||
====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==== | ====Info==== | ||
| Line 52: | Line 64: | ||
:[[API UseContainerItem|UseContainerItem(bagID,slot)]] - Uses an item located in [[bagID]] and slotID. | :[[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}}) ===== | ||