Create a control
const button = ui.new("Button")
button.text = "Start"
button.position = [20, 20]
button.size = [160, 40]
button.on_click = fn() {
debug.log("Start clicked")
}
The supported types are Panel, Text, and Button. Positions and sizes use playable-viewport pixels.
Find authored controls
Set a control's Script key in the editor. Use that key in your script.
const health = ui.find("health_text")
if health != nil {
health.text = "75 / 100"
}
Keys are case-sensitive. Display names are not script keys. ui.get() reports an error if the key is missing; ui.find() returns nil.
The optional document key must match the document loaded for Play.
Anchors
Set anchor to a named point such as "TopRight". Position becomes an offset from that point.
"Stretch" uses position as left/top margins and size as right/bottom margins.
Parent controls [BETA]
Set parent to another Ui handle, or nil to use the root. A hidden or disabled parent also affects its children.
Text layout [BETA]
Text and Button controls support font size, alignment, wrapping, padding, and line spacing. See the UI reference for allowed values.
Play changes
Runtime controls and property changes do not change the saved UI document. Starting a new Play session restores authored values.