ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   ZO_PreHookProtected (https://www.esoui.com/forums/showthread.php?t=9906)

Vaddi 09/05/21 08:24 PM

ZO_PreHookProtected
 
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.

Thanks in advance for any help.

Dolgubon 09/05/21 10:25 PM

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.

You can check out all the available hook functions here: https://github.com/esoui/esoui/blob/...ty/zo_hook.lua

Shinni 09/06/21 01:28 AM

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

Baertram 09/06/21 07:13 AM

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.

Vaddi 09/06/21 08:01 AM

Thanks for the info.

A PostHook won't help and I don't want to actually call UseItem.

I just want to take a peek at what is about to be used before it is used and in some cases abort the UseItem call. Maybe that can't be done.

Thanks again.


All times are GMT -6. The time now is 12:28 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI