button
A basic interactive push-button. It is used to trigger actions when clicked.
Signature
Section titled “Signature”local clicked = ui.button(label, size)Description
Section titled “Description”The button returns true for a single frame when it is pressed and released.
Because CSP scripts run every frame, you typically place this inside an if statement within your update loop.
Parameters
Section titled “Parameters”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
label | string | Yes | - | The text displayed on the button. |
size | vec2 | No | vec2(0, 0) | The dimensions of the button. 0 uses standard padding. |
Return Values
Section titled “Return Values”| Type | Description |
|---|---|
boolean | Returns true during the frame the button is clicked. |
Examples
Section titled “Examples”A simple button that logs a message when clicked.
if ui.button("Click Me") then ac.log("Button was pressed!")endCreating a wide button that spans 200 pixels.
local buttonSize = vec2(200, 40)local buttonClicked = ui.button("Large Action", buttonSize)
if buttonClicked then -- trigger actionend