Thread Tools Display Modes
06/04/15, 05:11 PM   #1
hoydyd
Join Date: May 2015
Posts: 7
Trouble Hiding Objects

Hello again,

I am having trouble hiding objects related to the reticle, such as the reticle itself, stealth text, reticle interact button etc

In the mean time i have been setting a Anchor offscreen if i wanted to hide the element, then restoring the original anchor when i want to show it, as calling SetHidden(true) seems to hide it until it shows after exiting UI, killing an enemy and other cases. I have registered events to try and combat this, but it seems that unless i set a delay on the function that was registered to the event, that the object wil reappear (seems to reappear within first 0.7-0.8 seconds). I am guessing that I need to somehow unregister an event on the object (?), as I have seen that function in zgoo, however I havent had any success while playing around with it.

Any ideas?

The method ive been using in the meantime does work, however I would rather see if i can somehow use SetHidden() so i dont have to store original anchors and such.

Thank you
  Reply With Quote
06/04/15, 11:49 PM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by hoydyd View Post
Any ideas?

The method ive been using in the meantime does work, however I would rather see if i can somehow use SetHidden() so i dont have to store original anchors and such.

Thank you
The reticle hidden state is updated by various events and functions. (Together with the stealth and disguise state)
All calling this function:
Lua Code:
  1. RETICLE:UpdateHiddenState()
The reticle control itself is:
Lua Code:
  1. RETICLE.reticleTexture
You could post-hook RETICLE:UpdateHiddenState or replace/overwrite RETICLE.reticleTexture.SetHidden.
  Reply With Quote
06/05/15, 12:04 AM   #3
hoydyd
Join Date: May 2015
Posts: 7
Originally Posted by votan View Post
The reticle hidden state is updated by various events and functions. (Together with the stealth and disguise state)
All calling this function:
Lua Code:
  1. RETICLE:UpdateHiddenState()
The reticle control itself is:
Lua Code:
  1. RETICLE.reticleTexture
You could post-hook RETICLE:UpdateHiddenState or replace/overwrite RETICLE.reticleTexture.SetHidden.
Sorry, but what do you mean by posti-hook?, and regarding the RETICLE.reticleTexture.SetHidden(), wouldn't that only hide the crosshair itself? or would i be able to control the visibility of the stealth eye, and the interaction display and so-on using that method?

Also, I have been using ZO_ReticleContainerReticle, ZO_ReticleContainerStealth etc rather than RETICLE, what is the differences between ZO_ReticleContainer and RETICLE?

Thank you for your help
  Reply With Quote
06/05/15, 01:24 AM   #4
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by hoydyd View Post
Sorry, but what do you mean by posti-hook?
I'm at work now, so I can not test what I'm writing, but it is basically:
Lua Code:
  1. local function HookReticle()
  2.   local baseUpdateHiddenState = RETICLE.UpdateHiddenState
  3.   -- Redefine UpdateHiddenState:
  4.   function RETICLE:UpdateHiddenState()
  5.     -- Do your pre-hook stuff
  6.     baseUpdateHiddenState(self)
  7.     -- Do your post-hook stuff
  8.   end
  9. end
or
Lua Code:
  1. local function HookReticleSetHidden()
  2.   local baseSetHidden = RETICLE.reticleTexture.SetHidden
  3.   function RETICLE.reticleTexture:SetHidden(hidden)
  4.     -- Modify hidden as needed
  5.     baseSetHidden(self, hidden)
  6.   end
  7. end
Call the Hook function(s) in your AddOnLoaded event handler.

Originally Posted by hoydyd View Post
and regarding the RETICLE.reticleTexture.SetHidden(), wouldn't that only hide the crosshair itself? or would i be able to control the visibility of the stealth eye, and the interaction display and so-on using that method?

Also, I have been using ZO_ReticleContainerReticle, ZO_ReticleContainerStealth etc rather than RETICLE, what is the differences between ZO_ReticleContainer and RETICLE?

Thank you for your help
I did not forget the parentheses.
I talk about the reference to the function, not calling it.

RETICLE is the instance of the controller class handling the ZO_ReticleContainer control and its child controls.
  Reply With Quote
06/05/15, 02:21 AM   #5
hoydyd
Join Date: May 2015
Posts: 7
Originally Posted by votan View Post
I'm at work now, so I can not test what I'm writing, but it is basically:
Lua Code:
  1. local function HookReticle()
  2.   local baseUpdateHiddenState = RETICLE.UpdateHiddenState
  3.   -- Redefine UpdateHiddenState:
  4.   function RETICLE:UpdateHiddenState()
  5.     -- Do your pre-hook stuff
  6.     baseUpdateHiddenState(self)
  7.     -- Do your post-hook stuff
  8.   end
  9. end
or
Lua Code:
  1. local function HookReticleSetHidden()
  2.   local baseSetHidden = RETICLE.reticleTexture.SetHidden
  3.   function RETICLE.reticleTexture:SetHidden(hidden)
  4.     -- Modify hidden as needed
  5.     baseSetHidden(self, hidden)
  6.   end
  7. end
Call the Hook function(s) in your AddOnLoaded event handler.


I did not forget the parentheses.
I talk about the reference to the function, not calling it.

RETICLE is the instance of the controller class handling the ZO_ReticleContainer control and its child controls.
Sorry, I sort of understand, but still have some confusion.

I think i just don't really understand some of the terms and what is meant by hooking, so i googled it and that i think i get what you mean.

Here:
Lua Code:
  1. local function HookReticle()
  2.   local baseUpdateHiddenState = RETICLE.UpdateHiddenState
  3.   -- Redefine UpdateHiddenState:
  4.   function RETICLE:UpdateHiddenState()
  5.     -- Do your pre-hook stuff
  6.     baseUpdateHiddenState(self)
  7.     -- Do your post-hook stuff
  8.   end
  9. end
So the first RETICLE.UpdateHiddenState is the reference for the UpdateHiddenState() function, which belongs in RETICLE (Also why is it RETICLE.Update.. instead of RETICLE:Update..) We grab it now as we will need to store this original function to use, as we then redefine the function and thus change its contents.

the function RETICLE:UpdateHiddenState() is replacing the function UpdateHiddenState() in RETICLE, so we are pretty much redefining what the UpdateHiddenState() function in RETICLE does, so in this case where your '--Do your post-hook stuff' comment is, I would call SetHidden(true) on the children of RETICLE?, and thus in my case in particular i do not need any pre-hook stuff? Also does the redefined function's placement being inside the hook function matter? if so, why? would it position inside a function mean that i would have to call the function differently, or would it still be just RETICLE:UpdateHiddenState().

But then whats the difference between that method, and simply calling the orininal RETICLE:UpdateHiddenState(), followed by a SetHidden(), wouldnt the reticle just toggle back on again as i described in the OP?

Am I on the right track or is my understanding/interpretation completely off?

Sorry for the bombardment of questions, I have always just called functions on ZO_ objects before and had no idea about these handlers(?). Was using these handlers(?) the intended way for manipulating objects?

Thank you for your help

EDIT: Nevermind on those questions above, I tried it out and it works perfectly and I think I understand it all, so basically its in a way similar to RegisterForEvent, but instead of an event on the event list, its whenever the UpdateHiddenState is called, right? (And you can do code before the function call) Also, in the original UpdateHiddenState(), it calls the SetHidden(value) function right? otherwise the second method (HookReticleSetHidden) wouldnt work. is that correct?

Last edited by hoydyd : 06/05/15 at 02:55 AM.
  Reply With Quote
06/05/15, 03:58 AM   #6
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by hoydyd View Post
EDIT: Nevermind on those questions above, I tried it out and it works perfectly and I think I understand it all, so basically its in a way similar to RegisterForEvent, but instead of an event on the event list, its whenever the UpdateHiddenState is called, right? (And you can do code before the function call) Also, in the original UpdateHiddenState(), it calls the SetHidden(value) function right? otherwise the second method (HookReticleSetHidden) wouldnt work. is that correct?
Yes, correct.


Inside UpdateHiddenState the SetHidden of that control is called based on GetUnitDisguiseState("player") and GetUnitStealthState("player")

function RETICLE:UpdateHiddenState() is a Lua shortcut for function RETICLE.UpdateHiddenState(self)

In Lua nearly everything is a variable. Including function names. Replacing/Overwritting a function is just assigning a new nameless function to a named table member/variable.
The overwritting takes place in the moment you do the assignment.
Putting the code into a function has two effects:
1. The scope of the "backup" variable is limited. So you know who can and will call the base function only.
2. The assignment=replacement is delayed to the moment everything is initialized (e.g. your saved variable=addon settings)

Otherwise you may get unexpected nil value errors. Happened to me

edit 1:
Originally Posted by hoydyd View Post
Was using these handlers(?) the intended way for manipulating objects?
Well, controls are just controls. Like your addon, there is always some additional code doing something with them.
And for a lot classes/instances ZOS is so kind to give public access via those global variables like RETICLE, PLAYER_INVENTORY and so on.

Last edited by votan : 06/05/15 at 04:10 AM.
  Reply With Quote
06/05/15, 10:34 PM   #7
hoydyd
Join Date: May 2015
Posts: 7
Originally Posted by votan View Post
Yes, correct.


Inside UpdateHiddenState the SetHidden of that control is called based on GetUnitDisguiseState("player") and GetUnitStealthState("player")

function RETICLE:UpdateHiddenState() is a Lua shortcut for function RETICLE.UpdateHiddenState(self)

In Lua nearly everything is a variable. Including function names. Replacing/Overwritting a function is just assigning a new nameless function to a named table member/variable.
The overwritting takes place in the moment you do the assignment.
Putting the code into a function has two effects:
1. The scope of the "backup" variable is limited. So you know who can and will call the base function only.
2. The assignment=replacement is delayed to the moment everything is initialized (e.g. your saved variable=addon settings)

Otherwise you may get unexpected nil value errors. Happened to me

edit 1:

Well, controls are just controls. Like your addon, there is always some additional code doing something with them.
And for a lot classes/instances ZOS is so kind to give public access via those global variables like RETICLE, PLAYER_INVENTORY and so on.
Thank you,

Just wondering, but in the function listed here: http://esodata.uesp.net/100010/src/i...e.lua.html#217

there is no mention of getting the disguise or stealth state. And i can't seem to find out what is inside the IsReticleHidden function. I mention this as I have an issue when reenabling the stealth eye, and i think i can fix it, but i cant really explore all thats happening during UpdateHiddenState(). the reticle works fine but the stealth eye either doesnt reappear, or depending on how i do it, looks like a weird half-eye fuzzy texture.

Any other way to see everything thats happening in that function?

Also, does an (m) next to a function in zgoo mean you cant access it or something?, having trouble with only one function and it has an (m) before it

I seems like RETICLE may be different to what i linked

Thank you

Last edited by hoydyd : 06/06/15 at 01:38 AM.
  Reply With Quote
06/06/15, 08:57 AM   #8
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by hoydyd View Post
Thank you,

Just wondering, but in the function listed here: http://esodata.uesp.net/100010/src/i...e.lua.html#217

there is no mention of getting the disguise or stealth state. And i can't seem to find out what is inside the IsReticleHidden function. I mention this as I have an issue when reenabling the stealth eye, and i think i can fix it, but i cant really explore all thats happening during UpdateHiddenState(). the reticle works fine but the stealth eye either doesnt reappear, or depending on how i do it, looks like a weird half-eye fuzzy texture.

Any other way to see everything thats happening in that function?
The source of your link seems out-dated. Look at the links shown here kindly given by Ayantir.
I think the "m" stands for "metadata". Meaning it is from a "class" definition.

CU
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Trouble Hiding Objects


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