Hooking a function used for OnUpdate.
Using the code below, the function called for OnUpdate won't get hooked using hooksecurefunc but will if you change it to HookScript.
hooksecurefunc will work for functions used for other scripts. I don't believe this was the way it worked previously. Lua Code:
Edit: Is this intended? Changing SomeDopeyfunc to a local function I get: [code] 1x A\A.lua:16: hooksecurefunc(): SomeDopeyfunc is not a function [C]: in function `hooksecurefunc' A\A.lua:16: in main chunk [code] |
I think you want to do:
Lua Code:
hooksecurefunc is designed to catch secure but mainly global functions, so thats why it might not be able to handle local ones. |
Quote:
I wasn't sure about the local thing. |
The syntax is hooksecurefunc([table,]index,function). If table is omitted, _G is assumed. The entire design of the function is to hook another function stored in index of table. This means it has to be accessible from the global namespace or a provided table. hooksecurefunc() doesn't operate on locals and trying to use it on a frame won't necessarily work unless someone is dumb enough to have a dynamic function like this: frame:SetScript("OnUpdate",function(self) self:OnUpdate(); end).
In addition, if any function is directly assigned as a handler, changing it in any way outside of Frame:HookScript() won't update the function pointer used. Meaning the original function as defined would be updated, but the reference given to the frame to use for a handler will still point to the old function instead of your hook. For example: Code:
function A() print("A"); end The end result is, if you need to hook a script handler, use Frame:HookScript(), that's what it's there for. |
I think I need to reevaluate my test.
Apparently this addon was working pre-7.x hooking the function used by OnUpdate and no longer does after clearing the error by changing line 14 to Code:
local textDisplay = self.Text--getglobal(self:GetName().."Text") |
My guess is they updated the XML.
From: Code:
<OnUpdate>CastingBarFrame_OnUpdate(self,elapsed)</OnUpdate> Code:
<OnUpdate function="CastingBarFrame_OnUpdate"/> |
Didn't realise hooksecurefunc simply replaced the hooked function, but that was easily confirmed.
Code:
local a = print |
Quote:
Same, I only found out about that when I tried to see with hooksecurefunc whether RemoveExtraSpaces/RunScript was changed, or pointing to something else Thought I was going crazy when the reference kept changing after I hooked it... every day you learn something new >< http://wow.gamepedia.com/API_hooksecurefunc Quote:
|
All times are GMT -6. The time now is 07:53 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI