Thread Tools Display Modes
04/04/14, 03:13 PM   #1
Froali
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 13
Question Hook after function?

Hi there,

I'm fairly new to the ESO Ui API and stumbled upon the ZO_PreHook function to take action before some function is processed. Is there an similiar function to take action after some function is finished? I was looking for something like ZO_PostHook, but didn't find anything using zGoo.

Some hints or workarounds would be nice

Froali
  Reply With Quote
04/04/14, 06:47 PM   #2
Dio
 
Dio's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 29
Originally Posted by Froali View Post
Hi there,

I'm fairly new to the ESO Ui API and stumbled upon the ZO_PreHook function to take action before some function is processed. Is there an similiar function to take action after some function is finished? I was looking for something like ZO_PostHook, but didn't find anything using zGoo.

Some hints or workarounds would be nice

Froali
I think you just have to make your own postHook. Only tested this in the Lua emulator..

Code:
foo = function()
	print("Foo")
end

local bar = function()
	print("Bar")
end

local postHook = function(funcName, callback)
	local tmp = _G[funcName]
	_G[funcName] = function()
		tmp()
		callback()
	end
end

postHook("foo", bar)

foo() -- Prints "Foo\nBar"
  Reply With Quote
04/05/14, 01:03 PM   #3
Froali
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 13
Thanks! That bit of code did the work. I just had to modify it a little to support a variable amount of parameters:

Code:
local postHook = function(funcName, callback)
  local tmp = _G[funcName]
  _G[funcName] = function(...)
    tmp(...)
    callback()
  end
end
  Reply With Quote
04/06/14, 02:27 AM   #4
ins
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 76
Any chance you could give a code example of it in use in the game?

Like, any way to hook the mouse menu that appears when you right click an item in your inventory, or a way to see what 'command' is executed when you select any of those menu options?

Tried to dig through it in Zgoo but couldn't really get very far with it.

Last edited by ins : 04/06/14 at 06:57 PM.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Hook after function?


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