Add lines to item tooltip safely
Adding lines to an item tooltip is rather tricky, especially when you get into recipes and other items that behave odd. The below code snippet allows you to add lines while ensuring they are only added once.
Snippet
local lineAdded = false local function OnTooltipSetItem(tooltip, ...) if not lineAdded then tooltip:AddLine("Hello World!") lineAdded = true end end local function OnTooltipCleared(tooltip, ...) lineAdded = false end GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem) GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
Posted by jnwhiteh at Mon, 27 Apr 2009 10:50:34 +0000