View Single Post
07/22/18, 04:16 PM   #11
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
As shown above the code should look like this:
Lua Code:
  1. ZO_PreHook("TogglePlayerWield", function()
  2.     d("TogglePlayerWield was used")
  3.     return false -- reutn false to run original function code of TogglePlayerWield afterwards!
  4. end

ZO_PreHook(objectTable, existingFunctionName, hookFunction)

objectTable: The name of an object (e.g. SMITHING) or if it is the global namespace (_G) you can just pass the function name existingFunctionName without the objectTable.

existingFunctionName: The name of the function you'd like to preHook, in string quotes " "

hookFunction: Your definded hook function or an anonymouse function within the prehook like shown above in my example code.

So your code should look like this e.g.

Lua Code:
  1. ZO_PreHook("TogglePlayerWield", function()
  2.     myAddon.TogglePlayerWield()
  3.     return false -- return false to run original function code of TogglePlayerWield afterwards!
  4. end)

This is the same:
Lua Code:
  1. ZO_PreHook(_G, "TogglePlayerWield", function()
  2.     myAddon.TogglePlayerWield()
  3.     return false -- return false to run original function code of TogglePlayerWield afterwards!
  4. end)
  Reply With Quote