In my addon (which adds a note to an item's tooltip if it is listed in a pre-built table), I need to add a check if an item is armor or weapon.
if (armor or weapon) then
According to Wowwiki there's an ItemType property that returns the type of an item (wowwiki.wikia.com/wiki/ItemType). I have the following code that works well, just need to add the item type check, so the note (Keep/Sell) will be displayed only on gear (armor or weapon) type items.
local itemSets = {
["Battleforge"] = "Keep",
["Exalted"] = "Keep",
["Imperial Leather"] = "Sell",
["Mystical"] = "Keep",
["Starfire"] = "Sell",
["Warmaul"] = "Keep",
}
local find = string.find
local function GameTooltip_OnTooltipSetItem(tooltip)
local itemName = tooltip:GetItem()
if not itemName then return; end
-- check if item is armor or weapon, if yes do the for loop.
for setName, action in pairs(itemSets) do
if find(itemName, setName) then
tooltip:AddLine(action)
break
end
end
end
GameTooltip:HookScript("OnTooltipSetItem", GameTooltip_OnTooltipSetItem)
Any ideas how to get ItemType information from tooltip:GetItem() so I can do the check?
In my addon (which adds a note to an item's tooltip if it is listed in a pre-built table), I need to add a check if an item is armor or weapon.
According to Wowwiki there's an ItemType property that returns the type of an item (wowwiki.wikia.com/wiki/ItemType). I have the following code that works well, just need to add the item type check, so the note (Keep/Sell) will be displayed only on gear (armor or weapon) type items.
Any ideas how to get ItemType information from tooltip:GetItem() so I can do the check?
Thanks.