functionoverlay.add(id, spec) → Element
Registers an element under a unique string id and returns the element table (the same spec, now with .id set). Adding with an existing id replaces it.
| Param | Type | Notes |
| id | string | Unique; namespace it, e.g. "mymod.panel". |
| spec | Element | See Element. |
functionoverlay.remove(id) → nil
Removes the element registered under id. Does nothing if no such element exists.
| Param | Type | Notes |
| id | string | The element's unique id (the same string you passed to overlay.add). |
functionoverlay.get(id) → Element | nil
Returns the registered element table for id. Mutating the returned table changes the element live.
| Param | Type | Notes |
| id | string | The element's unique id. |
| returns | The Element table, or nil if not found. |
functionoverlay.toggle() → nil
Toggles the overlay open/closed (same as Shift+Tab). Takes no parameters.
functionoverlay.open() → nil
Opens the overlay. Takes no parameters.
functionoverlay.close() → nil
Closes the overlay (and clears any text-field focus). Takes no parameters.
functionoverlay.isOpen() → boolean
Whether the overlay is currently open. Takes no parameters. Returns a boolean.
functionoverlay.setUserMode(id, mode) → nil
Sets a user override for an element's visibility mode. Ignored for elements whose lockMode is true.
| Param | Type | Notes |
| id | string | The element's unique id. |
| mode | string | One of "menu", "pinned", "hud" (see Element). |
functionoverlay.getUserMode(id) → string | nil
Returns the user override mode for an element.
| Param | Type | Notes |
| id | string | The element's unique id. |
| returns | string mode, or nil if none is set. |
functionoverlay.focus(elemId, childIdx) → nil
Gives keyboard focus to a textbox widget. Useful right after creating an element so the user can type immediately.
| Param | Type | Notes |
| elemId | string | The id of the panel element that holds the textbox. |
| childIdx | number | 1-based index of the textbox within that panel's children. |
functionoverlay.screenW() → number
Width of the window in pixels — use it to centre or right-align things. Takes no parameters.
functionoverlay.screenH() → number
Height of the window in pixels. Takes no parameters.
functionoverlay.textHeight(text, w, font) → number
How tall text will be once it is wrapped into a box w wide at size font, in pixels. This is the engine's own wrapper, not a rule that matches it — so a row laid out around the answer cannot drift from what gets drawn.
Use it to size a wrapping label, or to grow a row to fit one. A label given too little height loses its tail silently, which reads as the text simply being wrong.
local h = overlay.textHeight(s.label, 336, 14)
kids[#kids+1] = { type = "label", x = 18, y = y, w = 336, h = h, text = s.label }
y = y + math.max(46, h + 14)
functionoverlay.textLines(text, w, font) → number
The same measurement as a line count rather than a pixel height. Useful when the count itself is the decision — "does this still fit on one line?".
functionoverlay.mouseX() → number
Pointer X in screen pixels, or -1 until the mouse has moved once. Lets an element work out where inside itself the cursor is — which row of a list it is over, say — rather than only that it is somewhere inside. Still reported while the pointer is auto-hidden. Takes no parameters.
functionoverlay.mouseY() → number
Pointer Y in screen pixels, or -1 until the mouse has moved once. Takes no parameters.