View Single Post
08-13-15, 05:08 PM   #3
elcius
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Sep 2011
Posts: 75
lua has no problem with very large tables, just make an itemid to setid lookup table.
Lua Code:
  1. local setName =  {
  2. [1] = {  name = "Mystic's Regalia (Recolor)", items = {14090, 26008, 14094}, },
  3. -- [2......1778]
  4. [1779] = {  name = "Imperial Plate", items = {31436, 30002, 12424, 12425, 12422, 12427, 12429}, },
  5. }
  6.  
  7. -- make lookup table, ideally this would be pre-made
  8. local itemSet = {};
  9. for i,set in pairs(setName) do
  10.     for j, id in pairs(set['items']) do
  11.         itemSet[id] = i;
  12.     end
  13. end
  14.  
  15. function addline_gametip()
  16.     local itemName,itemLink = GameTooltip:GetItem();
  17.     if not itemLink then return end
  18.    
  19.     local itemId = itemLink:match('item:(%d+)');
  20.     local setIndex = itemSet[tonumber(itemId)];
  21.    
  22.     if setIndex and setName[setIndex] then
  23.         GameTooltip:AddLine("Transmog Set: " .. setName[setIndex]['name']);
  24.     end
  25.  end
  26.  
  27.  
  28. GameTooltip:HookScript("OnTooltipSetItem", addline_gametip);
  Reply With Quote