HUD
Opusbot draws script HUDs with a hybrid renderer:
| Kind | Drawn by | Notes |
|---|---|---|
| Text labels | Win32 GDI overlay | clean-room, no client memory |
| Filled / outline rects | Win32 GDI overlay | |
| Item sprites | In-client QML | client’s own appearance renderer |
Coordinates are game-window client pixels (top-left origin).
Toggle the GDI overlay with hud_overlay=0|1 in opusbot_cmd.txt. Module toggle buttons are separate (hud_buttons / hud_visible).
Create elements
Text
local label = HUD.new(24, 120, "Hello")
label:setColor(90, 190, 255)
label:setFontSize(14)
label:setText("HP: 100%")
Item sprite
-- number content => item icon
local icon = HUD.new(24, 160, 3031) -- platinum coin example
icon:setSize(32, 32)
-- or explicit:
local icon2 = HUD.newItem(60, 160, 3031, 34)
Panel (filled rect)
local panel = HUD.newRect(24, 120, 220, 100, 12, 14, 20, 205)
-- r,g,b,a background
Clear all
HUD.clear()
On full script reload the engine also clears HUD elements automatically.
Chainable methods
All methods return self for chaining:
| Method | Description |
|---|---|
:setText(s) | text content |
:setPos(x, y) | or :setPos({x=, y=}) |
:setSize(w, h) | rects / sprites |
:setColor(r,g,b[,a]) | text / outline |
:setBackgroundColor(r,g,b[,a]) | filled rect |
:setFontSize(px) | text |
:setItemId(id) | sprite item id |
:setVisible(bool) / :show() / :hide() | visibility |
:destroy() | remove element |
Unknown ZeroBot methods resolve to a chainable no-op so large scripts do not crash on unimplemented calls.
Layout tips
- Leave room for the module bar (top-left by default, ~
y = hud_top_margin). - Prefer semi-transparent panels (
a~ 180–220) so the game stays readable. - Throttle text updates (e.g. every 250 ms) — GDI redraws when the model revision changes; item JSON only changes when sprites change (by design, so live HP text does not thrash the client’s sprite renderer).
- Do not use pure
RGB(1,1,1)as a fill — that color is reserved as the GDI transparent key.
Module toggle bar (not Lua HUD)
Always-visible buttons (Cave / Heal / Target / Spells / Loot) are configured in opusbot_cmd.txt:
hud_visible=1
hud_anchor=tl
hud_top_margin=100
hud_buttons=cave:Cave:SET cave_enabled 1;heal:Heal:SET heal_enabled 1;...
Module buttons auto-color green = ON / red = OFF and toggle on click. They are QML, not HUD.* elements.
CustomModalWindow
CustomModalWindow.new(...) returns a chainable visual no-op until a full modal UI is wired. Scripts that only build windows will not crash, but nothing is drawn yet.