View Single Post
05-09-23, 09:34 PM   #5
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,334
In general, I have a variable keep track if I have hooked the script and only do so if I haven't.

For example:
Lua Code:
  1. local function OnScript(self)
  2. --  Do Stuff
  3. end
  4.  
  5. local Hooked={};
  6. hooksecurefunc(SomeFrameMixin,"SomeMethod",function(self)
  7.     if not Hooked[self] then
  8.         self:HookScript("ScriptType",OnScript);
  9.         Hooked[self]=true;
  10.     end
  11. end);

PS: I don't see a reason to not use :HookScript() when you're essentially reinventing it anyway.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 05-09-23 at 09:37 PM.
  Reply With Quote