WoW:API GetItemInfo: Difference between revisions

Change type links.
mNo edit summary
(Change type links.)
Line 1: Line 1:
<center>'''GetItemInfo''' ''-Documentation by [[user:Darjk|Darjk]]-''</center>
{{wowapi}}__NOTOC__


Return information about a specific item.
Return information about a specific item.


  args = GetItemInfo(itemID | "itemString");
  args = GetItemInfo(itemID or "itemString");
== Parameters ==
== Parameters ==
=== Arguments ===
=== Arguments ===
:(itemID or "itemString")
:(itemId or "[[itemString]]")


:;itemID : Integer - The numeric ID of the item. ie. 12345
:;itemId : Integer - The numeric ID of the item. ie. 12345
:;"itemString" : String - The full item ID in string format. ie. "item:12345:0:0:0"
:;"[[itemString]]" : String - The full item ID in string format, e.g. "item:12345:0:0:0"


=== Returns ===
=== Returns ===
:itemName, itemLink, itemQuality, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture
:itemName, itemString, itemQuality, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture


:;itemName : String - The name of the item.
:;itemName : String - The name of the item.
:;itemLink : String - The item link ie. "item:12345:0:0:0".
:;[[itemString]] : String - The item id in string format, e.g. "item:12345:0:0:0".
:;itemQuality : Integer - The [[API TYPE Quality|quality]] of the item.  The value is 0 to 6, which represents Poor to Artifact.
:;itemQuality : Integer - The [[API TYPE Quality|quality]] of the item.  The value is 0 to 6, which represents Poor to Artifact.
:;itemMinLeveL : Integer - The minimum level required to use the item, 0 being no level requirement.
:;itemMinLeveL : Integer - The minimum level required to use the item, 0 being no level requirement.
:;itemType : String - The [[API TYPE itemType|type]] of the item. Armor, Weapon, Quest, Key, etc.
:;[[itemType]] : String - The type of the item. Armor, Weapon, Quest, Key, etc.
:;itemSubType : String - The [[API TYPE itemType|sub type]] of the item. Enchanting, Cloth, Sword, etc.
:;itemSubType : String - The sub type of the item. Enchanting, Cloth, Sword, etc. See [[itemType]].
:;itemStackCount : Integer - How many of the item per stack. ie. 20 for Runecloth, 1 for weapon, 100 for Alterac Ram Hide, etc.
:;itemStackCount : Integer - How many of the item per stack. ie. 20 for Runecloth, 1 for weapon, 100 for Alterac Ram Hide, etc.
:;itemEquipLoc : String - Equip [[API TYPE itemEquipLoc|location]] of the item specified. The string contains the name a global string variable, such as "INVTYPE_HEAD", which contains the localized name of the location.
:;[[itemEquipLoc]] : String - Where the item may be equipped, if it can. The string returned is also the name of a global string variable, i.e. for "INVTYPE_HEAD" there is a INVTYPE_HEAD variable containing a localized, displayable name of the location.
:;itemTexture : String - The name and path for the inventory icon texture for the item.
:;itemTexture : String - The name and path for the inventory icon texture for the item.


Line 34: Line 34:
: This function will <b>ONLY</b> retrieve data that is in your local cache.
: This function will <b>ONLY</b> retrieve data that is in your local cache.
: If you have never seen the item that belongs to the Item ID or Item Link it will return ''nil''.
: If you have never seen the item that belongs to the Item ID or Item Link it will return ''nil''.
: All string returns (itemName, itemType, itemSubType, itemEquipLoc(until 1.9)) are localized.
: All string returns (itemName, itemType, itemSubType) are localized. Prior to 1.9, itemEquipLoc was localized also.
: itemString is a subset of an item's link, not the actual link returned from functions like GetContainerItemLink()


== Common usage ==
== Common usage ==
Line 42: Line 41:
   local itemId = nil;
   local itemId = nil;
   if ( type(link) == "string" ) then
   if ( type(link) == "string" ) then
  _,_, itemId = string.find(link, "item:(%d+):");
    _,_, itemId = string.find(link, "item:(%d+):");
  end
    if(itemId) then
  if ( itemId ) then
      return GetItemInfo(itemId);
  return GetItemInfo(itemId);
    end
   end
   end
  end
  end
Line 52: Line 51:
  local itemName, itemLink, itemQuality, itemLevel, itemType, itemSubType, itemCount, itemTexture  
  local itemName, itemLink, itemQuality, itemLevel, itemType, itemSubType, itemCount, itemTexture  
   = GetItemInfoFromItemLink(link);
   = GetItemInfoFromItemLink(link);
-- do stuff with the info.
Most people want to know how to get the item code needed to get item information (among them, me) so I decided to add it here. [[User:Sarf|Sarf]]


----
The above function will work with [[itemString]]s as well as [[itemLink]]s.
__NOTOC__
{{Template:WoW API}}
Anonymous user