API GetItemGem

104,537pages on
this wiki
Add New Page
Add New Page Talk0
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)
String - The Name of the Item, ex: "Hearthstone" (the item must be equiped or in your Inventory for this to work).
String - The itemLink, when Shift-Clicking items.
Number - The index of the desired gem. 1, 2, or 3

Returns Edit

itemName, itemLink
String - The name of the gem at the specified index.
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)
if gem2name then
  DEFAULT_CHAT_FRAME:AddMessage("Gem 2: "..gem2name..", Link: "..gem2Link)
if gem3name then
  DEFAULT_CHAT_FRAME:AddMessage("Gem 3: "..gem3name..", Link: "..gem3Link)


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]


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.

Also on Fandom

Random Wiki