View Single Post
10-03-18, 08:48 PM   #1
MuffinManKen
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 106
Problem reading Item tooltips for Recipes

I'm trying to read the tooltip data for a large number of items, but the basic code I'm using is having an issue; the tooltip is often incomplete. I write up a minimal test case and paste it into WoWLua using Design: Nightmare Tear as the item. No matter how many times I run it, the part of the recipe that is supposed to be after the item info is never there (mats, required skill).

Is there an error in my code or am I just not understanding how this should work?

Lua Code:
  1. tt_frame = tt_frame or CreateFrame("GameTooltip", "MuffinItemCacheTooltip", UIParent, "GameTooltipTemplate")
  2.  
  3. function myOnTooltipSetItem(self, arg1, arg2, arg3)
  4. print("myOnTooltipSetItem", arg1, arg2, arg3)
  5.     local item_name, item_link = self:GetItem()
  6.  
  7.     if(not item_link) then
  8.         print("no item link, returning", item_name, item_link);
  9.         return;
  10.     end;
  11.  
  12.     local item_id = tonumber(string.match(item_link, "item:([%d]+):"))
  13.     local printable = gsub(item_link, "\124", "\124\124");
  14.     print(item_name, item_link, printable,  item_id)
  15.  
  16.     local tt = {}
  17.  
  18.     for i=1,tt_frame:NumLines() do
  19.         local textLeft =  _G["MuffinItemCacheTooltipTextLeft"..i]:GetText()
  20.         local textRight = _G["MuffinItemCacheTooltipTextRight"..i]:GetText()
  21.         table.insert(tt, textLeft)
  22.         table.insert(tt, textRight)
  23.     end
  24.  
  25.     self:Hide();
  26.  
  27.     print("item id:", "   ", item_id, table.concat(tt," "))
  28.  
  29.  
  30. end
  31. tt_frame:SetScript("OnTooltipSetItem", myOnTooltipSetItem)
  32.  
  33. function TestTT(p_item_id)
  34.    print("----------------")
  35.    tt_frame:SetOwner(UIParent,"ANCHOR_NONE")
  36.    tt_frame:SetItemByID(p_item_id)
  37.  
  38. end
  39.  
  40. TestTT(49112)
  Reply With Quote