Thread Tools Display Modes
11-27-07, 08:58 AM   #1
SonicUK
A Deviate Faerie Dragon
 
SonicUK's Avatar
Join Date: Dec 2006
Posts: 12
How do I hook GameTooltip:OnTooltipSetItem ?

I want to add extra information to item stats shown in the tooltip. I just cant seem to get it to hook a function in that format. I'm not very experienced in lua
  Reply With Quote
11-27-07, 09:46 AM   #2
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Originally Posted by SonicUK
I want to add extra information to item stats shown in the tooltip. I just cant seem to get it to hook a function in that format. I'm not very experienced in lua
WoW Wiki: How To's


But I personally do:
Code:
local Orig_foo = foo
function foo(apple ,...)
   --Do stuff
   Orig_foo(apple ,...)
end
Or you could just add a line to the tooltip using
Code:
tooltip:AddDoubleLine(textLeft, textRight, textLeft.r, textLeft.g, textLeft.b, textRight.r, textRight.g, textRight.b);

Last edited by Slakah : 11-27-07 at 09:51 AM.
  Reply With Quote
11-27-07, 05:03 PM   #3
Tekkub
A Molten Giant
 
Tekkub's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 960
Not quite Slakah, he wants to hook a script handler not a function...

Code:
local orig = GameTooltip:GetScript("OnTooltipSetItem")
GameTooltip:SetScript("OnTooltipSetItem", function(frame, ...)
	-- do crap

	--Call hook, if it exists
	-- It might not exist if nothing else was using this script handler!
	if orig then return orig(frame, ...) end
end)
Also Slakah, if you don't return the values passed back from your hook call at the end, you risk breaking the hook chain. Always pass all args forward and returns back in the chain!
  Reply With Quote
11-27-07, 09:45 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
It's like a bad chain letter - you need to keep passing it along!
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
11-28-07, 03:09 AM   #5
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Ahhh thanks for the info.
  Reply With Quote
11-30-07, 01:14 PM   #6
SonicUK
A Deviate Faerie Dragon
 
SonicUK's Avatar
Join Date: Dec 2006
Posts: 12
Thanks, i'll give that a try!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How do I hook GameTooltip:OnTooltipSetItem ?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off