WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   How do I hook GameTooltip:OnTooltipSetItem ? (https://www.wowinterface.com/forums/showthread.php?t=13774)

SonicUK 11-27-07 08:58 AM

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 :)

Slakah 11-27-07 09:46 AM

Quote:

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);

Tekkub 11-27-07 05:03 PM

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!

Seerah 11-27-07 09:45 PM

It's like a bad chain letter - you need to keep passing it along!

Slakah 11-28-07 03:09 AM

Ahhh thanks for the info.

SonicUK 11-30-07 01:14 PM

Thanks, i'll give that a try!


All times are GMT -6. The time now is 08:25 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI