ui_sdkLua module
Build windows with the bundled Lua UI helper.
Import this library with local ui_sdk = require("ui_sdk"). ui_sdk.version is its installed version. ui_sdk.window opens and closes a ui window; the other helpers call the corresponding ui function inside it. Keep widget values between ticks.
ui_sdk.window(id, title, geometry, build)
Parameters: id and title identify the window; geometry contains x, y, width, height and optional style; build is a function receiving ui_sdk. Returns: true after the window is drawn, or nil, error if opening or closing fails. An error inside build raises a Lua error after the window closes.
local ui_sdk = require("ui_sdk")
local count = 0
function on_tick()
local ok, err = ui_sdk.window("counter", "Counter", {
x = 80, y = 120, width = 250, height = 150,
}, function(ui)
ui.text("Clicks: " .. count)
if ui.button("add", "Add") then count = count + 1 end
end)
if not ok then log.warn(err) end
endui_sdk.rgba(red, green, blue, alpha)
Parameters: Each channel is an integer from 0 to 255; alpha defaults to 255. Returns: Packed 0xAABBGGRR color. Invalid channels raise a Lua error.
local accent = ui_sdk.rgba(35, 95, 140)Controls
Each helper below has the same parameters and successful result as its ui counterpart. A failed call raises a Lua error, which ui_sdk.window closes safely before re-raising.
ui_sdk.text(message)
Parameters: Text. Result: Adds a label.
ui_sdk.text_colored(message, color)
Parameters: Text and packed color. Result: Adds a colored label.
ui_sdk.separator()
Parameters: None. Result: Adds a divider.
ui_sdk.same_line()
Parameters: None. Result: Uses the current row.
ui_sdk.button(id, label)
Parameters: Widget ID and label. Result: true once when clicked, otherwise false.
ui_sdk.checkbox(id, label, value)
Parameters: Widget ID, label, and previous boolean. Result: Current boolean.
ui_sdk.slider_float(id, label, value, minimum, maximum)
Parameters: Widget ID, label, previous number, and bounds. Result: Current number.
ui_sdk.input_text(id, label, value)
Parameters: Widget ID, label, and previous text. Result: Edited text.
local enabled = false
ui_sdk.window("options", "Options", { x = 80, y = 120, width = 250, height = 140 }, function(ui)
enabled = ui.checkbox("enabled", "Enabled", enabled)
end)