View Single Post
04/03/23, 12:44 PM   #6
Kismalyn
Join Date: Mar 2023
Posts: 4
woo! it worked. I did a combo of things from what you've said and some others.

For anyone else, here's what worked for me.

Code:
local settings = {
       activeWindow = false
}

local tlcFragment = nil

function Ui:ToggleShow()
	settings.activeWindow = not settings.activeWindow
	if(tlcFragment ~= nil) then
		if(settings.activeWindow == true) then
			tlcFragment:Show()
		else
			tlcFragment:Hide()
		end
	end
end

function Ui:AddTLCFragment(fragment)
	SCENE_MANAGER:GetScene("hud"):AddFragment(fragment)
	SCENE_MANAGER:GetScene("hudui"):AddFragment(fragment)
end

function Ui:CreateUI()
       -- /// blah blah blah code
        
        -- making this var global first seemed to avoid problems in the toggleShow function
        tlcFragment = ZO_SimpleSceneFragment:New(MyAppTLC)
	tlcFragment:SetConditional(function() return settings.activeWindow end)
	
	SCENE_MANAGER:GetScene("hud"):AddFragment(tlcFragment)
	SCENE_MANAGER:GetScene("hudui"):AddFragment(tlcFragment)
end
now it toggles on/off, and doesn't reappear after switching out of HUD/HUDUI even though its off due to the setConditional.

It was necessary to wrap in a ~= as it seemed to be hitting some kind of non-initialised race condition. Theres probably a better way of doing that part.

Thanks again for your help!
  Reply With Quote