Play Strawberry Docs

The language

How to write a mini-script: lines, values, statements, conditions, functions and texts in four languages.

Lines and blocks

  • Write one statement per line. # starts a comment.
  • Spaces and indentation do not matter, so indent as you like.
  • Every block ends with end.
  • Words are read without case (If is if). Texts keep their case.

A file holds uses and text lines and the blocks that start something, such as command, on and every.

A script pasted from a chat, a forum or an AI answer keeps its meaning even if its spaces change, because end closes the blocks. A missing end is reported on the line that opened the block: "The if opened on line 8 has no end."

Values

  • Numbers: 3, 2.5.
  • Texts: "Hello {name(player)}!". Braces hold any expression, {{ and }} write a brace, and \", \\ and \n are the escapes.
  • true, false and none.
  • Lists: [1, 2, "a"]. A list cannot hold a list.
  • Colour codes such as &a and &c work in texts sent to players.

Variables and saved values

  • x is a variable of this run only. Give it a value before you read it.
  • server.x is saved for the whole server.
  • player.x is saved for that player. So is <variable>.x when the variable holds a player.
  • Saved values stay across reloads and restarts.
  • A player or a translated text cannot be saved. Save the name or the text.

Values from events

A block gets values from what started it:

Value

Where

What it holds

player

every block except timers

The player. In a command, who typed it (none from the console).

sender

commands

Who ran the command.

message

chat

The chat line.

block, block_location

break, place, interact

The block and its place.

action

interact

For example left_click_block or right_click_air.

from_world, to_world

world change

The two worlds.

from_server, data

arrive

The server the player came from and the text sent with them (or none).

reason

move failed

Why the move failed.

You cannot change these values, and a command argument cannot use their names. A command's arguments are variables with their own names. Model item blocks have their own values.

These words belong to the language and cannot be names: and, or, not, is, has, contains, to, from, in, true, false, none, end, else, if, set, add, remove, delete, repeat, for, each, while, times, wait, stop, cancel, break, continue, server, permission and online.

Statements

Change variables

  • set x to <value>
  • add <value> to x adds a number, puts an item in a list or extends a text.
  • remove <value> from x subtracts a number or takes an item from a list.
  • delete x

Choose and repeat

  • if <condition>, else if <condition>, else and end.
  • repeat <n> times runs up to 10,000 times.
  • for each p in <list> runs once per item. players() is every player online.
  • while <condition> runs up to 10,000 rounds.
  • break leaves a loop, continue goes to the next round and stop ends the block.

Wait and cancel

  • wait <n> ticks, seconds or minutes pauses for up to one hour. The rest of the block runs later.
  • cancel stops the event (chat, break, place or interact). It comes before any wait.

Act in the game

  • message <text> [to <player>] sends a chat line. Without to, it goes to the block's player, or to whoever ran the command.
  • title <text> [subtitle <text>] [to <player>] and actionbar <text> [to <player>] show text on the screen.
  • sound "<key>" [to <player>] plays a game sound, such as "entity.experience_orb.pickup".
  • broadcast <text> sends a line to every player.
  • teleport [<player>] to <location> also works into another world.
  • give [<n>] <item> [to <player>] gives items, for example give 3 diamond. What does not fit in the inventory is not given.
  • take [<n>] <item> [from <player>] takes items.
  • gamemode survival, creative, adventure or spectator, optionally for <player>.
  • console "<command>" runs a console command that your uses console(...) line names.
  • log <text> writes a line to the server's console.
  • move sends players to a sub-server.

Most of these need a permission.

Conditions and operators

  • Compare with = (or is), != (or is not), <, <=, > and >=. Text comparisons ignore case.
  • Join conditions with and, or and not.
  • contains finds a text in a text or an item in a list.
  • Calculate with + - * / %. + also joins texts.
  • <player> has permission "<node>"
  • <player> has [<n>] <item>
  • <player> is in world "<name>"
  • <player> is online

In an if, false, none, 0, an empty text and an empty list count as no. Everything else counts as yes.

Functions

  • Players: name(p), online(name) (a player, or none), players([world]), gamemode(p) and count(p, "item").
  • Places: world(p) (also of a location), location(p), location(x, y, z[, world]), spawn([world]), main_world(), world_exists(name), x(loc), y(loc) and z(loc).
  • Numbers: random(a, b), round, floor, ceil, abs, min(a, b), max(a, b) and number(text) (none when the text is not a number).
  • Texts and lists: length(text or list), lower, upper and text(x).
  • Translated texts: lang("key", values...).

Texts in four languages

A text block holds one message in English (en), Spanish (es) and Turkish (tr). English is required. {0} and {1} stand for the values you hand to lang.

text
text welcome
  en "&eWelcome, {0}!"
  es "&e¡Bienvenido, {0}!"
  tr "&eHoş geldin, {0}!"
end

lang("welcome", name(player)) shows the text in the language of the player who reads it. A language you leave out shows the English text.

Use lang(...) on its own. Joined with other text, it shows the English line.

On this page