WoW:ItemLink: Difference between revisions

288 bytes added ,  21 July 2016
m
No edit summary
Line 2: Line 2:
{{wowapitype}}
{{wowapitype}}


An [[ItemLink]] is a string that can be processed by the WoW UI to produce UI item 'link' text for a [[item|game item]]. [[ItemLink]]s are [[itemString|ItemStrings]] with additional formatting to make in-game text controls display them as clickable hyperlinks. ItemLinks are returned various functions, including {{apif|GetAuctionItemLink}}, {{apif|GetContainerItemLink}}, {{apif|GetInventoryItemLink}}.
[[ItemLink]]s are [[itemString]]s with additional formatting for embedding 'link' text for a [[item|game item]] link, typically used for display in the UI such as text boxes that can display them as clickable hyperlinks. See {{apif|GetAuctionItemLink}}, {{apif|GetContainerItemLink}}, {{apif|GetInventoryItemLink}}.
 
|cff9d9d9d|Hitem:3299::::::::20:257::::::|h[Fractured Canine]|h|r


== Format ==
== Format ==


* <tt>"'''|cff9d9d9d'''"</tt> - Colorizes the link with a medium grey color (hex color code)
* |cff9d9d9d - Colorizes the link with a medium grey color (hex color code)
** The first two characters after pipe-c may be the alpha level, where <code>ff</code> is fully opaque.
** The first two characters after '|c' may be the alpha level, where 'ff' is fully opaque.
** The next three sets of two characters represent the red, green, and blue levels, just like HTML.
** The next three sets of two characters represent the red, green, and blue levels, just like HTML.
* <tt>"'''|H'''"</tt> - Hyperlink link data starts here
* |H - Hyperlink link data starts here
* <tt>"'''item:7073:0:0:0:0:0:0:0:0:0:0'''"</tt> - The embedded item string. See [[itemString]]. Changed in 5.0.4.
* item:7073:0:0:0:0:0:0:0:0:0:0:0:0 or item:7073:::::::::::: - the item string. See [[itemString]].
* <tt>"'''|h'''"</tt> - End of link, text follows
* |h - End of link, text follows
* <tt>"'''[Broken Fang]'''"</tt> - The actual text displayed
* [Broken Fang] - The actual text displayed
* <tt>"'''|h'''"</tt> - End of hyperlink
* |h - End of hyperlink
* <tt>"'''|r'''"</tt> - Restores color to normal
* |r - Restores color to normal


  |cff9d9d9d|Hitem:7073:0:0:0:0:0:0:0:80:0:0|h[Broken Fang]|h|r
  |cff9d9d9d|Hitem:7073::::::::::::|h[Broken Fang]|h|r


== Summary ==
== Summary ==


=== Example ===
=== Example ===
local itemLink =
    "|cff9d9d9d|Hitem:3299::::::::20:257::::::|h[Fractured Canine]|h|r"
  local itemString = string.match(itemLink, "item[%-?%d:]+")
  local itemString = string.match(itemLink, "item[%-?%d:]+")
Produces:
itemString == "item:3299::::::::20:257::::::"
This example extracts the itemString from a given itemLink using the string.match regex Lua function.
This example extracts the itemString from a given itemLink using the string.match regex Lua function.


Line 27: Line 33:


'''To obtain all the data within a hyperlink, you can use the following:'''
'''To obtain all the data within a hyperlink, you can use the following:'''
  local _, _, Color, Ltype, Id, Enchant, Gem1, Gem2, Gem3, Gem4, Suffix, Unique, LinkLvl, Name =
  local _, _, Color, Ltype, Id, Enchant, Gem1, Gem2, Gem3, Gem4,
  string.find(itemLink,
    Suffix, Unique, LinkLvl, Name = string.find(itemLink,
     "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")
     "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")
Note that this will accept any hyperlink (item/spell/quest/talent/achievement/tradeskill/etc), it will take itemstrings alone, or even just a single number.
Note that this will accept any hyperlink (item/spell/quest/talent/achievement/tradeskill/etc), it will take itemstrings alone, or even just a single number.
Line 49: Line 55:
*Enter the game and paste the information into the chat window
*Enter the game and paste the information into the chat window
*A clickable link for that item should appear
*A clickable link for that item should appear
== Changes ==
* Patch 5.0.4 - changed the number of [[itemString]] parameters from 10 to 11
* Patch 7.0.3 - in the 'itemString' portion place holder 0s can be removed or left blank to be assumed 0. For example ''|cff9d9d9d|Hitem:7073:0:0:0:0:0:0:0:80:0:0:0:0|h[Broken Fang]|h|r'' becomes ''|cff9d9d9d|Hitem:7073:::::::0:80::::|h[Broken Fang]|h|r''. See [[itemString]]


== Notes ==
== Notes ==
* The format of the link is similar for enchant, spell and quest links, with merely the "itemstring" changing. See [[spellString]], [[enchantString]] and [[questString]]
* The format of the link is similar for enchant, spell and quest links, with merely the "itemstring" changing. See [[spellString]], [[enchantString]] and [[questString]]
* Patch 5.0.4 - changed the number of [[itemString]] parameters from 10 to 11


== See ==
== See Also ==
* [[itemString]]
* [[itemString]]
* {{apif|GetContainerItemLink}}
* {{apif|GetContainerItemLink}}
* [[item|game item (item)]]
* [[item|game item (item)]]
* [[questString]], [[spellString]], [[enchantString]]
* [[questString]], [[spellString]], [[enchantString]]