WoW:ItemLink: Difference between revisions
mNo edit summary |
|||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:itemLink}} | {{DISPLAYTITLE:itemLink}} | ||
{{wowapitype}} | {{wowapitype}} | ||
An [[ItemLink]] is a string that can be process by the WoW UI to produce UI item 'link' text for a [[item|game item]]. [[ItemLink|ItemLinks]] 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}}. | |||
== Format == | |||
* <tt>"'''|cff9d9d9d'''"</tt> - Colorizes the link with a medium grey color (hex color code) | |||
* <tt>"'''|cff9d9d9d'''"</tt> | |||
** The first two characters after pipe-c may be the alpha level, where <code>ff</code> is fully opaque. | ** The first two characters after pipe-c may be the alpha level, where <code>ff</code> 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> | * <tt>"'''|H'''"</tt> - Hyperlink link data starts here | ||
* <tt>"'''item:7073:0:0:0:0:0:0:0:0:0'''"</tt> | * <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. | ||
* <tt>"'''|h'''"</tt> | * <tt>"'''|h'''"</tt> - End of link, text follows | ||
* <tt>"'''[Broken Fang]'''"</tt> | * <tt>"'''[Broken Fang]'''"</tt> - The actual text displayed | ||
* <tt>"'''|h'''"</tt> | * <tt>"'''|h'''"</tt> - End of hyperlink | ||
* <tt>"'''|r'''"</tt> | * <tt>"'''|r'''"</tt> - Restores color to normal | ||
|cff9d9d9d|Hitem:7073:0:0:0:0:0:0:0:80:0:0|h[Broken Fang]|h|r | |||
== Summary == | |||
=== Example === | |||
local itemString = string.match(itemLink, "item[%-?%d:]+") | local itemString = string.match(itemLink, "item[%-?%d:]+") | ||
This example extracts the itemString from a given itemLink using the string.match regex Lua function. | |||
== Details == | |||
'''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 = string.find(itemLink, "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?") | local _, _, Color, Ltype, Id, Enchant, Gem1, Gem2, Gem3, Gem4, 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?") | |||
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. | ||
== Printing links for debug == | === Printing links for debug === | ||
Printing out the contents of an item link is perhaps not so obvious; displaying it anywhere in-game will just show you a clickable link. Reformat it slightly to ruin the [[UI Escape Sequences|escape sequences]] and you'll see what it really looks like: | Printing out the contents of an item link is perhaps not so obvious; displaying it anywhere in-game will just show you a clickable link. Reformat it slightly to ruin the [[UI Escape Sequences|escape sequences]] and you'll see what it really looks like: | ||
Line 37: | Line 41: | ||
"124" is the ascii value of the "|" character. If you are writing this in a regular .lua file, feel free to go ahead and just use "|" and "||". However, if you're typing it in an in-game editor, it's better to use the ascii code escape to avoid problems. | "124" is the ascii value of the "|" character. If you are writing this in a regular .lua file, feel free to go ahead and just use "|" and "||". However, if you're typing it in an in-game editor, it's better to use the ascii code escape to avoid problems. | ||
== Notes == | |||
* 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 == | |||
* [[itemString]] | |||
* {{apif|GetContainerItemLink}} | |||
* [[item|game item (item)]] | |||
* [[questString]], [[spellString]], [[enchantString]] |
Revision as of 22:34, 25 September 2012
Warning: Display title "WoW API type: ItemLink" overrides earlier display title "itemLink".← API types
An ItemLink is a string that can be process by the WoW UI to produce UI item 'link' text for a game item. ItemLinks are ItemStrings with additional formatting to make in-game text controls display them as clickable hyperlinks. ItemLinks are returned various functions, including GetAuctionItemLink(), GetContainerItemLink(), GetInventoryItemLink().
Format
- "|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
ff
is fully opaque. - The next three sets of two characters represent the red, green, and blue levels, just like HTML.
- The first two characters after pipe-c may be the alpha level, where
- "|H" - Hyperlink link data starts here
- "item:7073:0:0:0:0:0:0:0:0:0:0" - The embedded item string. See itemString. Changed in 5.0.4.
- "|h" - End of link, text follows
- "[Broken Fang]" - The actual text displayed
- "|h" - End of hyperlink
- "|r" - Restores color to normal
|cff9d9d9d|Hitem:7073:0:0:0:0:0:0:0:80:0:0|h[Broken Fang]|h|r
Summary
Example
local itemString = string.match(itemLink, "item[%-?%d:]+")
This example extracts the itemString from a given itemLink using the string.match regex Lua function.
Details
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 = string.find(itemLink, "|?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.
Printing links for debug
Printing out the contents of an item link is perhaps not so obvious; displaying it anywhere in-game will just show you a clickable link. Reformat it slightly to ruin the escape sequences and you'll see what it really looks like:
link = GetContainerItemLink(0, 1); printable = gsub(link, "\124", "\124\124"); ChatFrame1:AddMessage("Here's what it really looks like: \"" .. printable .. "\"");
"124" is the ascii value of the "|" character. If you are writing this in a regular .lua file, feel free to go ahead and just use "|" and "||". However, if you're typing it in an in-game editor, it's better to use the ascii code escape to avoid problems.
Notes
- 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