Play Strawberry Docs

Events, commands and timers

What makes a mini-script run: events, commands and timers, with their arguments and permissions.

What starts a block

Everything a mini-script does happens inside a block. A block starts with one of these lines and ends with end:

  • on <event> runs when something happens in the game.
  • command /name adds a command.
  • every 30 seconds runs on a timer.
  • on button <name> runs when a menu or page button is pressed.
  • on use "<model id>" and its relatives run for model items.

Events

Event

Runs when

Values

on join

a player joins

player

on quit

a player leaves

player

on chat

a player chats

player, message

on break

a player breaks a block

player, block, block_location

on place

a player places a block

player, block, block_location

on interact

a player clicks

player, block, block_location, action

on death

a player dies

player

on respawn

a player respawns

player

on world change

a player changes world

player, from_world, to_world

on arrive

a player arrives from another server of your group

player, from_server, data

on move failed

a move you asked for fails

player, reason

on arrive and on move failed need uses subservers.

chat, break, place and interact can be stopped with cancel. The server waits for your block before it goes on, so keep these blocks short.

For a click in the air, block and block_location of on interact are none.

Commands

text
uses message
command /order <kind> <amount: number> [<note: text>]
  permission everyone
  usage "/order <kind> <amount> [note]"
  description "Order something."
  message "Ordered {amount} {kind}."
end

Arguments

  • Write <name> for one word, or <name: type>.
  • The types are word, text (the rest of the line, last only), number, player (someone online) and world.
  • Arguments in [...] are optional and come after the required ones.
  • Inside the block, each argument is a variable with its name.
  • player is who typed the command (none from the console), and sender is who ran it.
  • With missing or extra words, the player sees the usage line. A value that does not fit its type runs nothing and tells the player why.

Permission, usage and name

  • Every command needs a permission line in its block.
  • permission everyone lets everyone use it. permission op is for operators.
  • permission <name> needs the permission miniscript:<name>, which operators have by default.
  • usage sets the usage line. Without it, the line is made from the arguments.
  • description sets the command's description.
  • A command name is 1 to 32 letters, digits and _, and does not start with a digit.
  • Two mini-scripts cannot add the same command. Names of platform commands such as /marketplace and /store are not available.
  • A command named like one of the game's own, such as /debug, takes the plain name. The game's command stays available as /minecraft:debug.
Changing who may use a command

The server keeps the permission the command had when it was added. If you let more players use it, restart the server.

Timers

text
uses broadcast
every 10 minutes
  broadcast "Remember to vote for the server!"
end
  • Write a whole number of seconds or minutes. The shortest timer is 1 second.
  • The first run comes one period after the mini-script loads.
  • A timer has no player, so say who to act on: for each p in players(), then message "..." to p. A message without to in a timer does not load.

Waiting

  • wait 3 seconds pauses that run. The rest of the block runs later.
  • A wait is at most one hour, and a mini-script can have 64 paused runs at a time.
  • cancel comes before any wait, because the event is over after a wait.
  • If you save a new version while a run is paused, that run finishes on the version it started with.
  • A paused run does not survive a server restart.

Events your own actions cause

An action of a mini-script can fire an event: a teleport fires world change. The blocks for that event run right after the current run, and they cannot cancel it.

On this page