WoW:Hooking functions: Difference between revisions

no edit summary
No edit summary
Line 139: Line 139:


* I'm not totally sure about scoping, but it's probably a good idea to uniquely name the variable where you store the old functionality.  I tend to use a Pre_''addon''_''function name'' syntax.  Just don't use something like Old_''function name''
* I'm not totally sure about scoping, but it's probably a good idea to uniquely name the variable where you store the old functionality.  I tend to use a Pre_''addon''_''function name'' syntax.  Just don't use something like Old_''function name''
* An alternative is to store the old function as a member of a global variable, a la MyAddOn.FunctionToBeHooked = FunctionToBeHooked; FunctionToBeHooked = function() ...
* Warning! Blizzard has moved some pieces of the UI to be loaded on demand. The functions in those pieces cannot be hooked until they are loaded.
[[Category: HOWTOs]]
[[Category: HOWTOs]]
Anonymous user