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:
tt_frame = tt_frame or CreateFrame("GameTooltip", "MuffinItemCacheTooltip", UIParent, "GameTooltipTemplate")
function myOnTooltipSetItem(self, arg1, arg2, arg3)
print("myOnTooltipSetItem", arg1, arg2, arg3)
local item_name, item_link = self:GetItem()
if(not item_link) then
print("no item link, returning", item_name, item_link);
return;
end;
local item_id = tonumber(string.match(item_link, "item:([%d]+):"))
local printable = gsub(item_link, "\124", "\124\124");
print(item_name, item_link, printable, item_id)
local tt = {}
for i=1,tt_frame:NumLines() do
local textLeft = _G["MuffinItemCacheTooltipTextLeft"..i]:GetText()
local textRight = _G["MuffinItemCacheTooltipTextRight"..i]:GetText()
table.insert(tt, textLeft)
table.insert(tt, textRight)
end
self:Hide();
print("item id:", " ", item_id, table.concat(tt," "))
end
tt_frame:SetScript("OnTooltipSetItem", myOnTooltipSetItem)
function TestTT(p_item_id)
print("----------------")
tt_frame:SetOwner(UIParent,"ANCHOR_NONE")
tt_frame:SetItemByID(p_item_id)
end
TestTT(49112)