WoW:API GetContainerItemLink: Difference between revisions

m
Move page script moved page API GetContainerItemLink to WoW:API GetContainerItemLink without leaving a redirect
(Corrected valid range of the parameter bagID.)
m (Move page script moved page API GetContainerItemLink to WoW:API GetContainerItemLink without leaving a redirect)
 
(2 intermediate revisions by 2 users not shown)
Line 25: Line 25:
== 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(SearchString)
  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
       if (GetContainerItemLink(bag,slot)) then
       local item = GetContainerItemLink(bag,slot)
        if (string.find(GetContainerItemLink(bag,slot), SearchString)) then
      if item and item:find(search) then
          UseContainerItem(bag,slot)
        UseContainerItem(bag,slot)
        end
       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====
Anonymous user