Skip to content

Script UI

Menu controls and HUD windows.

-- The script's sidebar tab: a title and an icon
ui.sidebar("Radar", "crosshairs")
local enabled = ui.toggle("enabled", "Enabled", true)
local size = ui.slider_int("size", "Size", 100, 400, 200)
local mode = ui.combo("mode", "Mode", { "Dots", "Names" }, 1)
local tint = ui.color("tint", "Colour", color(150, 120, 255))
-- Hide the size slider while the toggle is off
enabled:on_change(function(on)
size:visible(on)
end)
-- on_change only runs on a menu edit, so set it once for the saved value
size:visible(enabled:get())
print(size:get(), mode:get(), tint:get())

Controls show on the script's own tab in the sidebar, in the order you create them. All of them are on the ui page.

  • The first argument is the control's id: 1 to 32 letters, digits, _ or -.
  • Values are saved in the active config.
  • ui.sidebar takes a Font Awesome Free solid icon name. An unknown name falls back to file-code.
local window = ui.window("info", "Info", vector.create(200, 60, 0))
local font = render.font("ui", 15)
window:on_paint(function(r)
-- r works like render, relative to the window's top-left
r.text(font, vector.create(8, 8, 0), color(255, 255, 255), game.map())
end)

Nyx draws the window's frame. Open the menu to drag it. Its position is saved. The render.*_3d functions don't work in a window.

A script can have 128 controls and 8 windows. The rest are on the Limits page.