→An Easier Way to Hook a Function?
m (Added category link) |
|||
| Line 33: | Line 33: | ||
So in this function, we first invoke the old function to let it do what it needs to do. Next, un-hide the level and hide the skull. Pretty simple right? | So in this function, we first invoke the old function to let it do what it needs to do. Next, un-hide the level and hide the skull. Pretty simple right? | ||
== An Easier Way to Hook a Function? == | |||
If you have the [[Sea]] library, then you can hook a function using [[Sea.util.hook]]. | |||
Sea.util.hook("OldFunctionName", "NewFunctionName", "before|after|hide|replace"); | |||
If you specify replace, then the old function will only be called if the new function returns true. | |||
If you use [[Sea.util.hook]], then you're also able to remove the hook later with [[Sea.util.unhook]]. | |||
Sea.util.unhook("OldFunctionName, "NewFunctionName); | |||
Using [[Sea.util.hook]] will take care of parameter passing, priorities, chains and making sure you can clean yourself up later. | |||
== Where to Call the Old Function == | == Where to Call the Old Function == | ||