View Single Post
04/17/23, 02:24 AM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
The answer is: In theory yes, practical no.
Of course you could store the original reference and restore it at some point.
But! If someone else is also hooking that, you would disable all hooks done after yours. Bad concept.
So, no, you should not do this!

What you could do is: Use a boolean for skipping any action.

/edit:
Or keep the hook, but the hook itself is just calling a function reference.
Lua Code:
  1. local current = MyAddon.MyFunction
  2. local function NoOp() end
  3. ZO_PostHook("ZO_Armory_Keyboard_CollapsedEntry_OnMouseUp", function(...) return current(...) end)
Now, *current* can be assigned with NoOp and at some point again with MyAddon.MyFunction.
That is a so-called "tail call". See https://www.lua.org/pil/6.3.html

Last edited by votan : 04/17/23 at 02:48 AM.
  Reply With Quote