Skip to content

Events and Actions

Kenny Lasyone edited this page Sep 22, 2026 · 1 revision

Events and actions

An event is something that happens, such as a click, typing or the screen opening. You attach actions (built-in steps) and optionally a script to it. Select a control and open the Events tab, or click Screen settings for the screen's own events.

Which events exist

Control Events
Button click
Text Box text_changed (each edit), submit (Enter)
Checkbox checked, unchecked
Slider, Dropdown value_changed
Item List item_click, item_primary, item_secondary (value = row index)
Every control hover, mouse_enter, mouse_leave (client only, at most 4 per second)
Screen open, close

Client and Server

Every event has two sides:

  • Client: "Runs locally for this screen." Instant visual changes on the player's own screen.
  • Server: "Trusted server actions. Preview simulates these." Runs on the Minecraft server: commands, messages, navigation, server scripts.

When an event fires, client actions run first on the player's screen, then the server is told which control and event fired, and the server runs its own actions from its own copy of your project. A modified client can't invent server actions or commands.

Adding actions

In the Events panel, pick the event, then under Client or Server click + Add action, choose a Type, and fill in Target and Value. Remove deletes an action. Actions run top to bottom.

Client actions

Type Target Value Does
set_text control Id new text Changes a control's text. ${var} works.
set_visible control Id true / false Shows or hides a control.
set_enabled control Id true / false Enables or disables a control.
set_value control Id new value Sets a slider, checkbox, text box, progress bar or dropdown value.
change_texture control Id image resource Swaps a control's image.
set_variable variable name value Sets a screen variable.
toggle_variable variable name – Flips a true/false variable.
play_sound – sound ID Plays a sound, for example minecraft:ui.button.click.
message – text Shows a message to the player.
open_ui – screen ID Asks to switch to another screen.
close_ui – – Closes the screen.

Server actions

Type Target Value Does
command – command Runs a Minecraft command as the player, with the player's permissions. The command is used exactly as written; player input is never inserted into it.
message – text Sends the player a chat message. ${var} works.
set_variable / toggle_variable variable value Changes the server's copy of a variable.
open_ui – screen ID Opens another screen of this project. (To open another project's screen, use a server script: ctx.ui.open("project:screen").)
close_ui – – Closes the screen.
player_inventory Item List Id – Fills an Item List with the player's inventory.
server_function function ID argument Calls a function registered by a mod or KubeJS. See [[Addon API

Permission level and cooldown (Server side)

Each Server handler has:

  • Permission level: 0 — Everyone, 1 — Moderator, 2 — Operator, 3 — Administrator, 4 — Owner. Players below it can't trigger the server side of this event.
  • Minimum interval (ticks): a per-player cooldown, 0–1200 ticks (20 ticks = 1 second). The default is 4. Reopening the screen doesn't reset it. Text and slider changes aren't delayed by it, so the final value always arrives.

Both are enforced by the server.

Scripts on events

Instead of (or as well as) actions, an event can run a JavaScript function. In the Events panel use New Script, write the function, then Save & Assign. See Scripting for the full workflow and API.

Variables

  • Each screen has string variables, with starting values set in Screen settings.
  • Show them in text with ${name}, and use them in conditions.
  • Variables reset every time the screen opens; they aren't saved between sessions.
  • Client and server each keep their own copy. The server mirrors trusted client changes (visibility, enabled state, variables) so it can check what's allowed. Server-side changes reach the client through script UI calls such as ctx.ui.setVariable.
  • The player's input is available on the server as event_value (and ctx.value in scripts). It can be shown in messages but is never put into commands.

Navigation between screens

Use open_ui with a screen ID from the same project; validation checks that the screen exists. A server script can also open another project's screen with ctx.ui.open("project_id:screen_id"). Navigation from the client side is a request; the server decides.

Clone this wiki locally