Add equipment sets to tooltip

This snippet will add a line to the tooltip of all equippable items, telling you whether or not they are a part of an equipment set.

Snippet

local numSets = GetNumEquipmentSets()
local inSet = {}

for i=1,numSets do
   local name, icon, setID = GetEquipmentSetInfo(i)
   local items = GetEquipmentSetItemIDs(name)
   for slot,item in pairs(items) do
      if inSet[item] then
         inSet[item] = inSet[item] .. ", " .. name
      else
         inSet[item] = name
      end
   end
end

local cleared = true
local function OnTooltipCleared(self)
   cleared = true   
end

local function OnTooltipSetItem(self)
   if cleared then
      local name, link = self:GetItem()
      if name then
         local equippable = IsEquippableItem(link)
         local item = link:match("Hitem:(%d+)")
         item = tonumber(item)
         if not equippable then
            -- Do nothing
         elseif inSet[item] then
            GameTooltip:AddLine("Equipment Set: " .. inSet[item], 0.2, 1, 0.2)
         else
            GameTooltip:AddLine("Item not in an equipment set", 1, 0.2, 0.2)
         end
         cleared = true
      end
   end
end

GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem)
Posted by jnwhiteh at Tue, 26 May 2009 19:45:53 +0000