Anyone know of an example of how to use ZO_PreHookProtected with UseItem?
I found some information and thought this would work:
ZO_PreHookProtected('UseItem', CheckItem) where CheckItem is my function. That throws a "nil found" error when loading.
Looks like that function does not exist. (/script d(ZO_PreHookProtected) --> nil ) When looking at lua errors, just 'nil found' could mean multiple possible errors, so it's best to actually say exactly what the error says. Plus, looking at line numbers can help as well. In this case, it's "function expected instead of nil". Which says that you're trying to use a function that does not exist. Checking the line numbers would say that it's occuring at the line you attempt to call the function, and not within any other function definitions.
In addition to the hook functions Dolgubon linked in his post, there is also SecurePostHook which can be used with protected functions. Unlike ZO_PreHook, SecurePostHook calls the hook after the original function. https://github.com/esoui/esoui/blob/...ntation.txt#L8
Use CallSecureProtected for protected functions, but not all work. UseItem would work e.g., but not for all items.
Preehooks and posthooks normally do not work on protected functions! SecurePostHook might work but I doubt it. There are other functions in the scope of these protected that need to be hooked into in most cases.