Define function
Lua Code:
local function TooltipHook(tooltipControl, method, linkFunc)
local origMethod = tooltipControl[method]
tooltipControl[method] = function(self, ...)
local link = linkFunc(...) -- you'll need the item link since you only wanna change names of certain items, here for demonstration ill just change name of every item
local orgText = GetString(SI_TOOLTIP_ITEM_NAME)
SafeAddString(SI_TOOLTIP_ITEM_NAME, "your text", 1)
origMethod(self, ...)
SafeAddString(SI_TOOLTIP_ITEM_NAME, orgText, 1)
end
end
Call in addon's initialize function
Lua Code:
TooltipHook(ItemTooltip, "SetBagItem", GetItemLink)
TooltipHook(ItemTooltip, "SetTradeItem", GetTradeItemLink)
TooltipHook(ItemTooltip, "SetBuybackItem", GetBuybackItemLink)
TooltipHook(ItemTooltip, "SetStoreItem", GetStoreItemLink)
TooltipHook(ItemTooltip, "SetAttachedMailItem", GetAttachedItemLink)
TooltipHook(ItemTooltip, "SetLootItem", GetLootItemLink)
TooltipHook(ItemTooltip, "SetTradingHouseItem", GetTradingHouseSearchResultItemLink)
TooltipHook(ItemTooltip, "SetTradingHouseListing", GetTradingHouseListingItemLink)
TooltipHook(ItemTooltip, "SetLink", ReturnItemLink)
TooltipHook(PopupTooltip, "SetLink", ReturnItemLink)
It won't change names on tooltips of equipped items, you'd need to find the function to hook on your own, I didn't bother finding it cuz I didn't need it for my alchemy addon. If you wanna see more how it works look into Alchemy Tooltips' code and look at file TooltipHooks.lua