Lua · Variables · Drawing

hud

Real HUD panels: the same style, drag and keep-out as the built-in widgets.

A HUD panel follows the menu style the user picked, can be dragged while the menu is open, and remembers its position in _settings.json. Call it every frame from on_frame, then draw your content from the returned corner.

FunctionWhat it does
hud.panel(id, title, w, h)Draws a panel with a header and returns where its content area starts.

#hud.panel

hud.panel(id, title, w, h)

Draws a panel with a header and returns where its content area starts.

Arguments

idstring
Unique inside this script. The saved position is keyed by it.
titlestring
Header text.
wnumber
Content width.
hnumber
Content height (the header is added on top).

Returns

number1
x of the content area
number2
y of the content area (below the header)
boolean3
visible: false while hidden or fading out. Skip drawing then.
  • The first time, the panel sits centred near the top of the screen.
Example
function on_frame()
    local x, y, shown = hud.panel("main", "Kills", 160, 40)
    if not shown then return end
    draw.text(x + 10, y + 10, "Kills: " .. kills, white, 15)
end