View Single Post
04/26/14, 08:18 AM   #4
Fathis Ules
Thief Guild Master
 
Fathis Ules's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 42
If :SetHidden(true) is your solution but something calls again :SetHidden(false) to revert your solution then you need to replace SetHidden by your function to filter out the calls made to SetHidden with false

In the sample I show you how to replace the SetHidden function by yours so you can decide then to pass the original execution to origZO_PlayerAttributeHealthBarLeftGloss to have the result of a normal SetHidden, or to not continue the execution , that's how you can forbid any call made to SetHidden

It is not specific to Lua, it is just called function hooking and is present in all the programming language, the only requirement is overwrite the pointer of the original function by your and to store a pointer of the original function in a local variable before you replace it so you can call later the original function from your.

Lua Code:
  1. local originalSetHiddenLeft = ZO_PlayerAttributeHealthBarLeftGloss.SetHidden
  2. local originalSetHiddenRight = ZO_PlayerAttributeHealthBarRightGloss.SetHidden
  3.  
  4. local function newSetHiddenLeft(self, hidden, ...)
  5.     if hidden == false then
  6.         --do nothing, meaning, SetHidden is disabled
  7.         return
  8.     end
  9.     originalSetHiddenLeft(self, hidden, ...) -- Calls the normal ZO_PlayerAttributeHealthBarLeftGloss.SetHidden
  10. end
  11.  
  12. local function newSetHiddenRight(self, hidden, ...)
  13.     if hidden == false then
  14.         --do nothing, meaning, SetHidden is disabled
  15.         return
  16.     end
  17.     originalSetHiddenRight (self, hidden, ...) -- Calls the normal ZO_PlayerAttributeHealthBarRightGloss.SetHidden
  18. end
  19.  
  20. ZO_PlayerAttributeHealthBarLeftGloss.SetHidden = newSetHiddenLeft
  21. ZO_PlayerAttributeHealthBarRightGloss.SetHidden = newSetHiddenRight

Last edited by Fathis Ules : 04/26/14 at 08:30 AM.
  Reply With Quote