Thread Tools Display Modes
09/05/21, 08:24 PM   #1
Vaddi
Join Date: Jun 2016
Posts: 14
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.
  Reply With Quote
09/05/21, 10:25 PM   #2
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 408
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
  Reply With Quote
09/06/21, 01:28 AM   #3
Shinni
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 167
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
  Reply With Quote
09/06/21, 07:13 AM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
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.
  Reply With Quote
09/06/21, 08:01 AM   #5
Vaddi
Join Date: Jun 2016
Posts: 14
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.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » ZO_PreHookProtected

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off