It should be enough to create your IO_BLUR_FRAGMENT fragment and add it to HUD_SCENE once
Code:
HUD_SCENE:AddFragment(IO_BLUR_FRAGMENT)
Attention: This will make it show as soon as you close a menu, or move, as the HUD_SCENE will be shown then.
To prevent this you'd have to either remove the fragment from the HUD_SCENE if it should not show, or add some condition at the
OnStateChange callback (see one of my last posts about it): As the FRAGMENT_STATE_SHOWING occurs -> check the actual stamina and if it's above the threshold hide the fragment again!
Shoudl be possible via IO_BLUR_FRAGMENT:Hide()
For your stamina OnPowerUpdate checks:
Scene fragments should use the base class ZO_HideableSceneFragmentMixin, and that class provides a function
:SetHiddenForReason()
Code:
ZO_HideableSceneFragmentMixin:SetHiddenForReason(reason, hidden, customShowDuration, customHideDuration)
So you could use that function to show/hide the fragment based on the stamina percentage:
Lua Code:
IO_BLUR_FRAGMENT:SetHiddenForReason("StaminaThresholdChecks_FreeTextAfaik", (staminaPercent > thresholdValue and true) or false, 0, 0)
Edit:
Example code
Lua Code:
local function hideTLCIfNotStaminaThresholdMet()
return currentPlayerStamina > thresHoldStamina --return true = hide, if stamina is high enough
end
local fragment = ZO_HUDFadeSceneFragment:New(TestTLC, nil, 0)
local function OnTestTLCFragmentStateChange(oldState, newState)
if newState == SCENE_FRAGMENT_SHOWING then
d("[TestTLC]Fragment showing")
fragment:SetHiddenForReason("ShouldntShow", hideTLCIfNotStaminaThresholdMet(), 0, 0)
--elseif newState == SCENE_FRAGMENT_HIDDEN then
end
end
fragment:RegisterCallback("StateChange", OnTestTLCFragmentStateChange)
--Hide in menus/Show at fighting UI
HUD_SCENE:AddFragment(fragment)