"Custom" meaning it's unreleased code that I wrote for my own use. I can still post the tooltip code used in it.
Base Code:
Lua Code:
local Hooked={};
local Hooks={
OnTooltipSetItem=function(self)
local _,link=self:GetItem();
if link then
local _,_,quality,ilvl,clvl,mcat,scat,stack,_,_,price=GetItemInfo(link);
self:AddLine(" ");
self:AddDoubleLine(("%sLv %s %s|r"):format(ITEM_QUALITY_COLORS[quality or 1].hex,ilvl or "???",_G["ITEM_QUALITY"..(quality or 1).."_DESC"]),(stack or "??").." Stack");
local count,total=GetItemCount(link),GetItemCount(link,true);
if total>0 then
local firstline=true;
if count>0 then self:AddDoubleLine(firstline and "On Hand" or " ",("Bags: %d"):format(count)); firstline=false; end
if count<total then self:AddDoubleLine(firstline and "On Hand" or " ",("Bank: %d"):format(total-count)); firstline=false; end
self:AddDoubleLine(" ",("Total: %d"):format(total));
else
self:AddDoubleLine("On Hand","Total: 0");
end
self:AddLine(" ");
self:AddDoubleLine("Vendor:",price and GetCoinTextureString(price) or "???");
self:AddDoubleLine("Req/Item Level:",("%s/%s"):format(clvl or "???",ilvl or "???"));
self:AddDoubleLine("Category:",("%s - %s"):format(mcat or "???",scat or "???"));
self:AddLine(link:match("|H(.-)|h"));
end
end;
OnTooltipSetUnit=function(self)
local _,unit=self:GetUnit();
if unit then
self:AddDoubleLine(" ",("unit:%s"):format(unit));
self:AddLine(UnitGUID(unit));
end
end;
OnTooltipSetSpell=function(self)
local sname,srank,sid=self:GetSpell();
if sid then
self:AddDoubleLine(("%s(%s)"):format(sname,srank),("spell:%d"):format(sid));
end
end;
};
local function HookTooltip(tooltip)
if Hooked[tooltip] then return; end
for i,j in pairs(Hooks) do tooltip:HookScript(i,j); end
Hooked[tooltip]=true;
end
hooksecurefunc(getmetatable(GameTooltip).__index,"SetOwner",function(self) if not Hooked[self] then HookTooltip(self); end end);
Insecure workaround:
Lua Code:
local LinkFuncs={
SetQuestItem=GetQuestItemLink;
SetQuestLogItem=GetQuestLogItemLink;
SetMerchantItem=GetMerchantItemLink;
SetTradeSkillItem=function(skill,reagent) return reagent and GetTradeSkillReagentItemLink(skill,reagent) or GetTradeSkillItemLink(skill); end;
};
local ItemLink;
local Meta=getmetatable(GameTooltip).__index;
do local GetItem=Meta.GetItem;
function Meta:GetItem(...)
local name,link=GetItem(self,...);
if link and link:match("|Hitem:0[:|]") and ItemLink then link=ItemLink; end
if name and link and #name<=0 then name=link:match("|h%[(.-)%]|h") or ""; end
return name,link;
end
end
for i,j in pairs(LinkFuncs) do
local func=Meta[i];
if func then
Meta[i]=function(self,...)
ItemLink=j(...);
func(self,...);-- Script hooks run here
ItemLink=nil;
end
end
end