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 /nameadds a command.every 30 secondsruns 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 |
|---|---|---|
| a player joins |
|
| a player leaves |
|
| a player chats |
|
| a player breaks a block |
|
| a player places a block |
|
| a player clicks |
|
| a player dies |
|
| a player respawns |
|
| a player changes world |
|
| a player arrives from another server of your group |
|
| a move you asked for fails |
|
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
uses message
command /order <kind> <amount: number> [<note: text>]
permission everyone
usage "/order <kind> <amount> [note]"
description "Order something."
message "Ordered {amount} {kind}."
endArguments
- Write
<name>for one word, or<name: type>. - The types are
word,text(the rest of the line, last only),number,player(someone online) andworld. - Arguments in
[...]are optional and come after the required ones. - Inside the block, each argument is a variable with its name.
playeris who typed the command (none from the console), andsenderis 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
permissionline in its block. permission everyonelets everyone use it.permission opis for operators.permission <name>needs the permissionminiscript:<name>, which operators have by default.usagesets the usage line. Without it, the line is made from the arguments.descriptionsets 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
/marketplaceand/storeare 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.
The server keeps the permission the command had when it was added. If you let more players use it, restart the server.
Timers
uses broadcast
every 10 minutes
broadcast "Remember to vote for the server!"
end- Write a whole number of
secondsorminutes. 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(), thenmessage "..." to p. Amessagewithouttoin a timer does not load.
Waiting
wait 3 secondspauses 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.
cancelcomes before anywait, 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.