→Notes
mNo edit summary |
(→Notes) |
||
| Line 26: | Line 26: | ||
The ''hookfunc'' is invoked after the original function, and receives the same parameters; return values from hookfunc are discarded. | The ''hookfunc'' is invoked after the original function, and receives the same parameters; return values from hookfunc are discarded. | ||
If another addon, or the same addon, replaces ''functionName'' after you use this function to hook it, ''hookfunc'' will no longer fire. ... except of course if your new function calls the old original! | |||
If another addon, or the same addon, replaces ''functionName'' after you use this function to hook it, ''hookfunc'' will no longer fire. | |||
hooksecurefunc("ToggleBackpack", function(...) | hooksecurefunc("ToggleBackpack", function(...) | ||
print("ToggleBackpack called.") | print("ToggleBackpack called.") | ||
| Line 39: | Line 37: | ||
After hooksecurefunc() is used on a function, setfenv() throws an error when attempted on that function | After hooksecurefunc() is used on a function, setfenv() throws an error when attempted on that function | ||
You cannot "unhook" a function that is hooked with this function except by a UI reload. | You cannot "unhook" a function that is hooked with this function except by a UI reload. Calling hooksecurefunc() multiple times only ''adds'' more hooks to be called. | ||
hooksecurefunc("ToggleBackpack", function() print(1) end) | |||
hooksecurefunc("ToggleBackpack", function() print(2) end) | |||
ToggleBackpack() | |||
> 1 | |||
> 2 | |||