Play Strawberry Docs

Buttons of menus and pages

How a button of your menus and pages runs a mini-script block and hands it values.

Connect a button

You need the Mini-scripts script and the UI script on your server. Menus and pages are made in the UI manager (see Menus and screens).

  1. In the UI manager, set A click runs to A Mini-script and type a name. In a menu file this is "function": "starter_kit".
  2. Write a block with on button and the same name in a mini-script.
text
uses message, items
on button starter_kit
  if player.kit_taken
    message "&cYou already took the starter kit."
    stop
  end
  give 8 bread
  set player.kit_taken to true
  message "&aHere is your starter kit."
end

What a press does

  • Every on button block with that name runs, in all running mini-scripts, in the order of their names.
  • The block gets player, the one who pressed.
  • It does what your uses line and your consent allow.
  • A press is not a game event, so cancel does not load there.
  • One player's presses run at most four times a second. Check inside the block what must not happen twice.
  • Only your own menus and pages start these blocks. No command and no other script can.

Names

  • A button has either a command or a Mini-script, not both.
  • A name is up to 32 letters, digits and _, and does not start with a digit.
  • In the menu, write it in lower case. In the mini-script, case does not matter.
  • A name that no running mini-script has does nothing for the player. The server's console says so once.

Values from the button

A button can hand the block values: "function": {"name": "order", "args": ["{kind}", "{amount}", "{note}"]}. In the UI manager, add them under Values for the Mini-script. A value is fixed text, {player}, {uuid} or, in a dialog, a field.

The block takes them as arguments, written like those of a command:

text
uses message
on button order <kind> <amount: number> [<note: text>]
  message "Ordered {amount} {kind}."
end
  • A button hands over at most 8 values of up to 256 characters each.
  • Each value fills one argument, in order, and is checked against its type: a word has no space, a number is a number, a player is online, a world exists.
  • Here a text argument can stand anywhere.
  • If a value does not fit, the block does not run and the player is told why.
  • If there are too many values, or a required one is missing, the block does not run and the console says so.
  • A value is never run as code. What a player typed is their own text, so check it before you put it in a console line.

On this page