Play Strawberry Docs

Examples

Five complete mini-scripts to copy: a welcome, an announcer, a spawn command, a chat filter and a starter-kit button.

Use an example

Each example is a starter in the panel:

  1. On the Mini-scripts tab, press New mini-script.
  2. Type a name, choose the starter and press Create.
  3. If it needs your consent, press Allow.

All texts in them are in English, French, Spanish and Turkish.

Welcome

Greets a joining player and counts their visits. It needs no consent.

text
# Welcome: greets a player when he joins, and counts his visits.

uses message

text welcome
  en "&eWelcome, {0}! This is your visit number {1}."
  fr "&eBienvenue, {0} ! C'est ta visite numéro {1}."
  es "&e¡Bienvenido, {0}! Esta es tu visita número {1}."
  tr "&eHoş geldin, {0}! Bu senin {1}. ziyaretin."
end

on join
  add 1 to player.visits
  message lang("welcome", name(player), player.visits)
end
  • uses message declares the one thing it does.
  • player.visits is saved for each player, so the count goes on after a restart.
  • lang("welcome", name(player), player.visits) picks the text in the player's language and fills {0} and {1}.

Announcer

Sends one of two lines to everyone every 10 minutes, in turn. Allow broadcast for it.

text
# Announcer: a line to everyone every 10 minutes, in turn.

uses broadcast

text vote
  en "&bLike the server? Tell your friends about it!"
  fr "&bTu aimes le serveur ? Parles-en à tes amis !"
  es "&b¿Te gusta el servidor? ¡Cuéntaselo a tus amigos!"
  tr "&bSunucuyu sevdin mi? Arkadaşlarına anlat!"
end

text rules
  en "&bBe kind in chat. Have fun!"
  fr "&bSois gentil dans le chat. Amuse-toi bien !"
  es "&bSé amable en el chat. ¡Diviértete!"
  tr "&bSohbette nazik ol. İyi eğlenceler!"
end

every 10 minutes
  add 1 to server.turn
  if server.turn % 2 = 0
    broadcast lang("vote")
  else
    broadcast lang("rules")
  end
end

server.turn is saved for the whole server and counts the rounds. % is the remainder, so even rounds say one line and odd rounds the other.

Spawn

/spawn takes the player to the main world's spawn after 3 seconds. Allow teleport for it.

text
# /spawn: back to the main world's spawn after 3 seconds without moving away.

uses message, teleport

text going
  en "&7Going to spawn in 3 seconds..."
  fr "&7Retour au spawn dans 3 secondes..."
  es "&7Volviendo al spawn en 3 segundos..."
  tr "&73 saniye içinde spawn'a gidiyorsun..."
end

command /spawn
  permission everyone
  description "Back to the spawn."
  message lang("going")
  wait 3 seconds
  if player is online
    teleport to spawn()
  end
end

wait 3 seconds pauses this run only. if player is online checks that the player is still there.

No swearing

Stops chat lines that contain a word from your list. Change the list to your own words. It needs no consent.

text
# No swearing: stops chat lines with words from a list. Change the list to your own words.

uses message

text blocked
  en "&cPlease keep the chat friendly."
  fr "&cMerci de garder le chat amical."
  es "&cPor favor, mantén el chat amistoso."
  tr "&cLütfen sohbeti dostça tut."
end

on chat
  for each word in ["badword", "worseword"]
    if message contains word
      cancel
      message lang("blocked")
      stop
    end
  end
end

cancel stops the chat line before anyone sees it, and stop ends the block so the player is told only once.

Starter kit button

A menu or page button gives each player a kit once. Give the button the Mini-script name starter_kit (see Buttons of menus and pages). Allow items for it.

text
# Starter kit: a button of a menu or page gives each player the kit once.
# The button's file names it: "function": "starter_kit" (set it in the UI manager).

uses message, items

text starter_given
  en "&aHere is your starter kit."
  fr "&aVoici ton kit de départ."
  es "&aAquí tienes tu kit inicial."
  tr "&aİşte başlangıç kitin."
end

text starter_already
  en "&cYou already took the starter kit."
  fr "&cTu as déjà pris le kit de départ."
  es "&cYa recogiste el kit inicial."
  tr "&cBaşlangıç kitini zaten aldın."
end

on button starter_kit
  if player.kit_taken
    message lang("starter_already")
    stop
  end
  give 8 bread
  set player.kit_taken to true
  message lang("starter_given")
end

player.kit_taken is saved for the player, so the kit is given once, even after a restart.

Try a mistake

Delete the last end of the welcome example and press Save. The file does not load and the tab says Has errors. The problem is on line 12, where the on join block opens: that block has no end. If the welcome example is running, it keeps running until you fix the file. See When a file is broken.

On this page