I modify the code with my lib, if I use thread to call the myOnTooltipSetItem and make it wait until next OnUpdate, I get the require material and level texts.
So those text aren't generated together, we need a little delay to get all the result.
Lua Code:
Scorpio "Test" ""
tt_frame = tt_frame or CreateFrame("GameTooltip", "MuffinItemCacheTooltip", UIParent, "GameTooltipTemplate")
__Async__() -- mark the function as thread
function myOnTooltipSetItem(self, arg1, arg2, arg3)
Next() -- wait for the next OnUpdate
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)
You may use the C_Timer.After to do the trick.