View Single Post
07-16-17, 01:37 PM   #7
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Hooking functions is a staple part of doing something in response to something that doesn't have a direct or reliable event or the event doesn't pass the data you want, especially if you're going off what another addon is doing.

To explain what Ketho used, there are three ways to hook something:

Code:
hooksecurefunc("GlobalFunction",yourFunction) -- used if the function is in _G by itself, like GetItemInfo()

hooksecurefunc(table,"FuncInTable",yourFunction) -- what Ketho used, this is for functions inside a global table, like C_TradeSkillUI or frame functions like RegisterEvent or SetPoint

frame:HookScript("OnWhatever",yourFunction) -- used to hook action scripts for frames, like OnHide, OnShow, OnEnter, etc.
All three pass the exact arguments the original functions used, so if you used the first one on GetItemInfo(), the first argument in yourFunction will be the item name, item ID, or item link that was just given to GetItemInfo().
  Reply With Quote