onOverlayOpen

This event get triggered when the CET Overlay gets shown.

Use this to keep track of the overlays state, and e.g. to only draw your own UI when CETs overlay is visible. Use it in conjunction with onOverlayClose to get a proper on/off switch case.

Usage Example

Display a warning message when the CET Overlay is opened:

init.lua
-- onOverlayOpen
registerForEvent('onOverlayOpen', function()
    
    -- get player
    local player = Game.GetPlayer()
    
    -- bail early if player doesn't exists
    if not player then
        return
    end
    
    -- display warning message
    player:SetWarningMessage('Overlay is open')

end)

Advanced Example

Render an ImGui window when the CET Overlay is opened:

This example use the onDraw event, which is triggered continuously. Make sure to check the documentation before any modification.

init.lua
-- set initial var
local isOverlayVisible = false

-- onOverlayOpen
registerForEvent('onOverlayOpen', function()
    isOverlayVisible = true
end)

-- onOverlayClose
registerForEvent('onOverlayClose', function()
    isOverlayVisible = false
end)

-- onDraw
-- this event is triggered continuously
registerForEvent('onDraw', function()
    
    -- bail early if overlay is not open
    if not isOverlayVisible then
        return
    end
    
    -- draw ImGui window
    if ImGui.Begin('Window Title', ImGuiWindowFlags.AlwaysAutoResize) then
        ImGui.Text('Hello World!')
    end
    
    ImGui.End()
    
end)

Last updated