Posted by taco-man on Sat, 24 Sep 2011 10:51:27
I had a question about the snippet provided on this site for adding a line to a tooltip (located here ). According to the description its only supposed to add one line to the tooltip, but it always ends up adding the line twice. i tried even just copy pasting that snippet into its own addon with no other code (and disabling all other addons) but it still seems to add the Hello World! text twice (in two separate lines) to all the item tooltips. I'm a total noob and am pretty sure i must just be missing something stupid. Does anyone have any ideas or suggestions of things to try regarding this? Any help you can provide would be very much appreciated. Snippet code provided below.
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)
EDIT: Screenshot example included.
Posted by jnwhiteh on Sat, 24 Sep 2011 15:13:22
I cannot reproduce this issue. You also don't need this code in an addon, you can run it in WowLua without any issues (like almost all snippets). Here's what I've done:
- Log into the game with no addons other than WowLua enabled
- Paste the code given into a page, run the page
- Mouse over an item in my containers
- Mouse over an item in my inventory
In both cases it works properly.
Posted by taco-man on Sat, 24 Sep 2011 20:47:38
i figured out my mistake. I'm completely new to addon programming, but the code was getting called twice (once from the addon.toc file and once from the addon.xml file) so it was hooking the tooltip function both times. I will be driving down to the bookstore and buying your book today. I just want to say thank you for this wonderful resource/info you provide on your website and the quick response, it is very appreciated. I look forward to working through your book. Have a great day!
Posted by jnwhiteh on Sat, 24 Sep 2011 21:31:47
Ah great ,glad you were able to figure it out!