Wikia

WoWWiki

API GetItemGem

Talk0
102,281pages on
this wiki
WoW API < GetItemGem

Takes an item with a gem in it, and an index from 1-3, and returns the name and link for the gem at that index.

itemName, itemLink = GetItemGem("name"|"itemlink", index) 

Parameters Edit

Arguments Edit

(itemName or "itemLink", index)
itemName 
String - The Name of the Item, ex: "Hearthstone" (the item must be equiped or in your Inventory for this to work).
"itemLink
String - The itemLink, when Shift-Clicking items.
index 
Number - The index of the desired gem. 1, 2, or 3

Returns Edit

itemName, itemLink
itemName 
String - The name of the gem at the specified index.
itemLink 
String - The gem's item Link; you will see the clickable Link instead of the string. (String, such as: "|cff0070dd|Hitem:24033:0:0:0:0:0:0:0|h[Solid Star of Elune]|h|r")

Example Edit

local itemLink = "|cff0070dd|Hitem:27773:3010:2729:2729:2739:0:0:0|h[Barbaric Legstraps]|h|r"
local gem1name, gem1Link = GetItemGem(itemLink, 1)
local gem2name, gem2Link = GetItemGem(itemLink, 2)
local gem3name, gem3Link = GetItemGem(itemLink, 3)
if gem1name then
  DEFAULT_CHAT_FRAME:AddMessage("Gem 1: "..gem1name..", Link: "..gem1Link)
end
if gem2name then
  DEFAULT_CHAT_FRAME:AddMessage("Gem 2: "..gem2name..", Link: "..gem2Link)
end
if gem3name then
  DEFAULT_CHAT_FRAME:AddMessage("Gem 3: "..gem3name..", Link: "..gem3Link)
end

ResultEdit

As long as [Barbaric Legstraps], [Bright Living Ruby], and [Shifting Nightseye] all exist in your local cache, you will see the following lines in your chat frame:
Gem 1: Bright Living Ruby, Link: [Bright Living Ruby]
Gem 2: Bright Living Ruby, Link: [Bright Living Ruby]
Gem 3: Shifting Nightseye, Link: [Shifting Nightseye]

DetailsEdit

This function will ONLY 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.
Using the name may be ambiguous if you have more than one of the named item.

Around Wikia's network

Random Wiki