Lua · Examples

HUD

Panels that look like the built-in widgets, drag with the menu open and remember their spot.

Each snippet runs as-is: copy it, press From Clipboard on the Lua page, turn it on. Quick start

#A basic panel

Call it every frame. Draw from the returned corner.

hud_1.lua
function on_frame()
    local x, y, shown = hud.panel("info", "Info", 180, 30)
    if not shown then return end
    draw.text(x + 10, y + 7, "Map: " .. globals.map(), color(235, 238, 245), 14)
end

#Panel that grows with its rows

The height can change every frame.

hud_2.lua
function on_frame()
    local list = game.players()
    local x, y, shown = hud.panel("alive", "Alive", 180, #list * 18 + 8)
    if not shown then return end
    for i, p in ipairs(list) do
        draw.text(x + 10, y + 4 + (i - 1) * 18, p.name .. "  " .. p.health, color(235, 238, 245), 13)
    end
end

#Show only in a match or with the menu open

So the user can still place the panel from the main menu.

hud_3.lua
function on_frame()
    if not globals.in_match() and not globals.menu_open() then return end
    local x, y, shown = hud.panel("clock", "Round", 120, 30)
    if shown then draw.text(x + 10, y + 7, string.format("%.0f s", game.time()), color(240, 242, 246), 14) end
end

Full scripts

Complete scripts with a header and settings, ready to use or change.