Script menus and clicks
current_player.set_ui_menu(true) opens that player's script menu. Their cursor appears over the game, and their game input stops while it's open. Clicking one of their visible, placed widgets marked with set_clickable(…, true) runs the script's on widget click event for that player:
Part of a script
on widget click: do
-- current_player clicked script_widget[clicked_widget].
if clicked_widget == 5 then
current_player.score += 1
current_player.set_ui_menu(false)
end
end
current_player.set_ui_menu(true)- Opens that player's script menu;
falsecloses it. current_player.is_ui_menu_open()- 1 while it's open. It gives a value: read it into a number.
on widget click: do … end- Runs once for each click the host accepts.
current_playeris the player who clicked. clicked_widget- The clicked widget's number, inside the event.
- Clickable widgets light up under the cursor. A click counts only on a widget that has a position, is clickable and is shown to that player, while their menu is open.
- On a controller the D-pad walks the clickable widgets, its first press landing on one, and lights the one it is on as the cursor would. A clicks it.
- Escape opens the ordinary pause menu, for settings or leaving the game; Resume or Escape returns to the script menu. Only the script closes the menu.
- Widgets are plain text, numbers and colors sent by the host. Players' PCs never run script code, and a click only tells the host which widget was pressed.
