ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   detect if HUD hidden or shown (https://www.esoui.com/forums/showthread.php?t=10550)

sinnereso 05/22/23 04:52 PM

detect if HUD hidden or shown
 
Looking for a way to detect if the HUD is shown. ive been been trying things like this but no success.

Code:

local hud = SCENE_MANAGER:GetScene("hud")
if hud:IsHidden() then

im able to with callbacks for 3 other related scenes but I'm trying to avoid that if possible.

**EDIT
figured it out :)

Code:

local hudScene = SCENE_MANAGER:GetScene("hud")
if hudScene:GetState() == SCENE_SHOWN then


Baertram 05/23/23 01:25 AM

Maybe helps too:
https://wiki.esoui.com/Fragments_in_...t_state_change

Sharlikran 05/23/23 02:15 AM

Code:

    if IsGameCameraUIModeActive() or IsUnitInCombat("player") then
        return
    end


Baertram 05/23/23 03:18 AM

Attention: IsUnitInCombat("player") does not tell you if you are in HUD mode as you can be in combat having the menus open or not!

sinnereso 05/23/23 12:49 PM

Quote:

Originally Posted by Baertram (Post 47819)

yeh I was previously using 3 state changes for crafting machines but was more callbacks than I wanted and events driving my code savage. I prefer events that I can fully turn on and off via options as I have many features so for me its key they can properly completely shut down any feature they are not using and its no longer firing anything related.

So I reversed my thinking and switched to:

Code:

EVENT_MANAGER:RegisterForEvent("MyAddon", EVENT_CRAFTING_STATION_INTERACT, MyAddon.AutoMeticulous)
EVENT_MANAGER:RegisterForEvent("MyAddon", EVENT_END_CRAFTING_STATION_INTERACT, MyAddon.AutoMetReturn)

with a filters in the functions for different things with:

Code:

if craftSkill ~= 0 and craftSkill ~= 1 and craftSkill ~= 2 and craftSkill ~= 3 and craftSkill ~= 6 and craftSkill ~= 7 then return end
and

Code:

local deconCraftScene = SCENE_MANAGER:GetScene("smithing")
local deconEnchantScene = SCENE_MANAGER:GetScene("enchanting")
local deconAssistScene = SCENE_MANAGER:GetScene("universalDeconstructionSceneKeyboard")
if deconCraftScene:GetState() ~= SCENE_SHOWN and deconEnchantScene:GetState() ~= SCENE_SHOWN and deconAssistScene:GetState() ~= SCENE_SHOWN then

etc etc.


ExoY 05/23/23 02:03 PM

you can also just register the same event multiple times for different features

Baertram 05/24/23 04:11 AM

You should not use the fixed numbers 0 ,1 and 2 etc. but the constants the game provides.
The constants type used for any API function or event are provided at the API documentation txt file:

Code:

* EVENT_CRAFTING_STATION_INTERACT (*[TradeskillType|#TradeskillType]* _craftSkill_, *bool* _sameStation_, *[CraftingInteractionMode|#CraftingInteractionMode]* _craftMode_)
Search for TradeskillType in the same txt filet o get the possible constants:
Code:

h5. TradeskillType
* CRAFTING_TYPE_ALCHEMY
* CRAFTING_TYPE_BLACKSMITHING
* CRAFTING_TYPE_CLOTHIER
* CRAFTING_TYPE_ENCHANTING
* CRAFTING_TYPE_INVALID
* CRAFTING_TYPE_JEWELRYCRAFTING
* CRAFTING_TYPE_PROVISIONING
* CRAFTING_TYPE_WOODWORKING


You will find those constants and their values via merTorchbug ingame too, using /tb and then click on the constants tab (search is top left).
e.g. enter CRAFTING_ and it should list all + their values.

Better use those as the numbers MIGHT (did) change in the future and 0 will stay 0 but CRAFTING_TYPE_INVALID might change to soemthing like -1 or similar and break your code then!

This applies to all API functions and events and callbacks.




Quote:

Originally Posted by ExoY (Post 47824)
you can also just register the same event multiple times for different features

Yes, only make sure to change the unique eventName "MyAddon" you specify to really be unique or you just overwrite your event callback!


Code:

EVENT_MANAGER:RegisterForEvent("MyAddon" .. tostring(craftingType), ...
btw: "MyAddon" (if you really use that in your addon RidinDirty as the unique event name) is not unique enough!
You might break other addons using the same.
!!!Please change that at ALL events in your addons to use a really unique name, like YOUR addon's real name, and not a generic "My Addon" or similar !!!
e.g. use RidinDirty.name if this exists

sinnereso 05/24/23 04:31 PM

Quote:

Originally Posted by Baertram (Post 47825)
You should not use the fixed numbers 0 ,1 and 2 etc. but the constants the game provides.
The constants type used for any API function or event are provided at the API documentation txt file:

Code:

* EVENT_CRAFTING_STATION_INTERACT (*[TradeskillType|#TradeskillType]* _craftSkill_, *bool* _sameStation_, *[CraftingInteractionMode|#CraftingInteractionMode]* _craftMode_)
Search for TradeskillType in the same txt filet o get the possible constants:
Code:

h5. TradeskillType
* CRAFTING_TYPE_ALCHEMY
* CRAFTING_TYPE_BLACKSMITHING
* CRAFTING_TYPE_CLOTHIER
* CRAFTING_TYPE_ENCHANTING
* CRAFTING_TYPE_INVALID
* CRAFTING_TYPE_JEWELRYCRAFTING
* CRAFTING_TYPE_PROVISIONING
* CRAFTING_TYPE_WOODWORKING


You will find those constants and their values via merTorchbug ingame too, using /tb and then click on the constants tab (search is top left).
e.g. enter CRAFTING_ and it should list all + their values.

Better use those as the numbers MIGHT (did) change in the future and 0 will stay 0 but CRAFTING_TYPE_INVALID might change to soemthing like -1 or similar and break your code then!

This applies to all API functions and events and callbacks.





Yes, only make sure to change the unique eventName "MyAddon" you specify to really be unique or you just overwrite your event callback!


Code:

EVENT_MANAGER:RegisterForEvent("MyAddon" .. tostring(craftingType), ...
btw: "MyAddon" (if you really use that in your addon RidinDirty as the unique event name) is not unique enough!
You might break other addons using the same.
!!!Please change that at ALL events in your addons to use a really unique name, like YOUR addon's real name, and not a generic "My Addon" or similar !!!
e.g. use RidinDirty.name if this exists

ty I always forget that.. ill get that updated soon.. And no I dont ever use MyAddon anywhere. I do that here for posts so as to keep my RidinDirty secret sauce a secret =p


All times are GMT -6. The time now is 02:03 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI