WoW:API GetItemInfo: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
m (Move page script moved page API GetItemInfo to API GetItemInfo without leaving a redirect)
 
(25 intermediate revisions by 21 users not shown)
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.
itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType,
itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice =
    GetItemInfo(itemID or "itemString" or "itemName" or "itemLink")


args = GetItemInfo(itemID | "itemString");
== Parameters ==
== Parameters ==
=== Arguments ===
=== Arguments ===
:(itemID or "itemString")
:(itemId or "[[itemString]]" or "itemName" or "[[itemLink]]")
 
:;itemId
:: Integer - The numeric ID of the item. ie. 12345
:;[[itemString]]
:: String - The full item ID in string format, e.g. "item:12345:0:0:0:0:0:0:0".
:::Also supports partial [[itemString]]s, by filling up any missing ":x" value with ":0", e.g. "item:12345:0:0:0"
 
:;itemName
:: String - The Name of the Item, ex: "Hearthstone"
:::The item must have been equiped, in your bags or in your bank once in this session for this to work.


:;itemID : Integer - The numeric ID of the item. ie. 12345
:;[[itemLink]]
:;"itemString" : String - The full item ID in string format. ie. "item:12345:0:0:0"
:: String - The [[itemLink]], when Shift-Clicking items.


=== Returns ===
=== Returns ===
:itemName, itemLink, itemRarity, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture
:"itemName", "[[itemLink]]", itemRarity, itemLevel, itemMinLevel, "[[itemType]]", "itemSubType", itemStackCount, "[[itemEquipLoc]]", "invTexture", "itemSellPrice"


:;itemName : String - The name of the item.
:;itemName
:;itemLink : String - The item link ie. "item:12345:0:0:0".
:: String - The name of the item.
:;itemRarity : Integer - The value is 0 to 6, which represents Poor to Artifact.
:;[[itemLink]]
:;itemMinLeveL : Integer - The minimum level required to use the item, 0 being no level requirement.
:: String - The item Link; you will see the clickable Link instead of the string. (String, such as: "|cFFFFFFFF|Hitem:12345:0:0:0|h[Item Name]|h|r")
:;itemType : String - The [[API TYPE itemType|type]] of the item. Armor, Weapon, Quest, Key, etc.
:;itemRarity
:;itemSubType : String - The [[API TYPE itemType|sub type]] of the item. Enchanting, Cloth, Sword, etc.
:: Integer - The [[API TYPE Quality|quality]] of the item. The value is 0 to 7, which represents Poor to Heirloom.
:;itemStackCount : Integer - How many of the item per stack. ie. 20 for Runecloth, 1 for weapon, 100 for Alterac Ram Hide, etc.
:;itemLevel
:;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.
:: Integer - The item level of this item.
:;itemTexture : String - The name and path for the inventory icon texture for the item.
:;itemMinLevel
:: Integer - The minimum level required to use the item, 0 meaning no level requirement.
:;[[itemType]]
:: String - The type of the item: Armor, Weapon, Quest, Key, etc.
:;itemSubType
:: String - The sub-type of the item: Enchanting, Cloth, Sword, etc. See [[itemType]].
:;itemStackCount
:: Integer - How many of the item per stack: 20 for Runecloth, 1 for weapon, 100 for Alterac Ram Hide, etc.
:;[[itemEquipLoc]]
:: String - Where the item may be equipped, if it can. If not equippable, this is an empty string, "". The string returned is also the name of a global string variable, i.e. for "INVTYPE_HEAD", _G["INVTYPE_HEAD"] is a localized, displayable name of the location.
:;itemTexture
:: String (number) - Texture Id of the item icon.
:;itemSellPrice
:: Integer - Items vendor value, in copper. Will need to be parsed into gold, silver, copper. Format ggggsscc.


== Example ==
== Example ==
  local sName, sLink, iQuality, iLevel, sType, sSubType, iCount = GetItemInfo(16846);
  local sName, sLink, iRarity, iLevel, iMinLevel, sType, sSubType, iStackCount = GetItemInfo(16846);
  message(sName..","..iQuality..","..sType..","..iCount);
  message(sName..","..iRarity..","..sType..","..iStackCount);


====Result====
====Result====
Line 32: Line 56:


==Details==
==Details==
: 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) are localized. Prior to 1.9, itemEquipLoc was localized also.
: All string returns (itemName, itemType, itemSubType, itemEquipLoc(until 1.9)) are localized.
: itemString is a subset of an item's link, not the actual link returned from functions like GetContainerItemLink()
 
== Common usage ==
 
function GetItemInfoFromItemLink(link)
  local itemId = nil;
  if ( type(link) == "string" ) then
  _,_, itemId = string.find(link, "item:(%d+):");
  end
  if ( itemId ) then
  return GetItemInfo(itemId);
  end
end
local link = FunctionThatGetsItemLink(arg1, arg2);
local itemName, itemLink, itemQuality, itemLevel, itemType, itemSubType, itemCount, itemTexture
  = 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]]


----
== Changes ==
__NOTOC__
* Patch 3.2 - 11th returned value is the Vendor Sell Price for that item.
{{Template:WoW API}}
* Patch 7.0.3 - itemTexture is now returned as a texture id, type number, rather than the full texture path as a string from before.

Latest revision as of 04:46, 15 August 2023

WoW API < GetItemInfo

Return information about a specific item.

itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType,
itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice =
    GetItemInfo(itemID or "itemString" or "itemName" or "itemLink")

Parameters[edit]

Arguments[edit]

(itemId or "itemString" or "itemName" or "itemLink")
itemId
Integer - The numeric ID of the item. ie. 12345
itemString
String - The full item ID in string format, e.g. "item:12345:0:0:0:0:0:0:0".
Also supports partial itemStrings, by filling up any missing ":x" value with ":0", e.g. "item:12345:0:0:0"
itemName
String - The Name of the Item, ex: "Hearthstone"
The item must have been equiped, in your bags or in your bank once in this session for this to work.
itemLink
String - The itemLink, when Shift-Clicking items.

Returns[edit]

"itemName", "itemLink", itemRarity, itemLevel, itemMinLevel, "itemType", "itemSubType", itemStackCount, "itemEquipLoc", "invTexture", "itemSellPrice"
itemName
String - The name of the item.
itemLink
String - The item Link; you will see the clickable Link instead of the string. (String, such as: "|cFFFFFFFF|Hitem:12345:0:0:0|h[Item Name]|h|r")
itemRarity
Integer - The quality of the item. The value is 0 to 7, which represents Poor to Heirloom.
itemLevel
Integer - The item level of this item.
itemMinLevel
Integer - The minimum level required to use the item, 0 meaning no level requirement.
itemType
String - The type of the item: Armor, Weapon, Quest, Key, etc.
itemSubType
String - The sub-type of the item: Enchanting, Cloth, Sword, etc. See itemType.
itemStackCount
Integer - How many of the item per stack: 20 for Runecloth, 1 for weapon, 100 for Alterac Ram Hide, etc.
itemEquipLoc
String - Where the item may be equipped, if it can. If not equippable, this is an empty string, "". The string returned is also the name of a global string variable, i.e. for "INVTYPE_HEAD", _G["INVTYPE_HEAD"] is a localized, displayable name of the location.
itemTexture
String (number) - Texture Id of the item icon.
itemSellPrice
Integer - Items vendor value, in copper. Will need to be parsed into gold, silver, copper. Format ggggsscc.

Example[edit]

local sName, sLink, iRarity, iLevel, iMinLevel, sType, sSubType, iStackCount = GetItemInfo(16846);
message(sName..","..iRarity..","..sType..","..iStackCount);

Result[edit]

Message box will pop-up with - "Giantstalker's Helmet,4,Armor,1".

Details[edit]

  • 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) are localized. Prior to 1.9, itemEquipLoc was localized also.

Changes[edit]

  • Patch 3.2 - 11th returned value is the Vendor Sell Price for that item.
  • Patch 7.0.3 - itemTexture is now returned as a texture id, type number, rather than the full texture path as a string from before.