WoW:API GetInventoryItemLink: Difference between revisions

Added an example
(Added an example)
Line 12: Line 12:


=== Returns ===
=== Returns ===
:link
:;link : String - The link string for the specified item, or nil if the slot is empty.
 
== Example ==
 
=== Code ===
local mainHandLink = GetInventoryItemLink("player",GetInventorySlotInfo("MainHandSlot"))
local _, _, itemCode = strfind(mainHandLink, "(%d+):")
local _, _, _, _, _, itemType = GetItemInfo(itemCode)
DEFAULT_CHAT_FRAME:AddMessage(itemType)


:;link : String - The link string for the specified item, or nil if the slot is empty.
=== Results ===
 
Prints the subtype of the mainhand weapon - for example "Mace" or "Sword".
 
=== Comments ===
 
The 2rd line of the example is used to strip down the link returned by the function into a format that [[API GetItemInfo|GetItemInfo]] will accept.  You can't pass a link from [[API GetInventoryItemLink|GetInventoryItemLink]] to [[API GetItemInfo|GetItemInfo]] directly.
----
----
__NOTOC__
__NOTOC__
Anonymous user