Control
Decide which blocks run, how often, and when.
if [true/false]
Runs the blocks inside only when the condition is true. When it is false they are skipped and the script carries on below.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | true/false | Something that is true or false, such as a comparison. |
Script: if condition { }
if [true/false] / else
Runs the first group of blocks when the condition is true, and the group under else when it is false.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | true/false | Something that is true or false, such as a comparison. |
Script: if condition { } else { }
repeat [number] times
Runs the blocks inside a number of times, one pass after the other. Counts above 10,000 are treated as 10,000.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | number | How many times to run the blocks inside. |
Script: repeat count { }
for each [variable] in [list]
Runs the blocks inside once for every item in a list, putting the current item in the variable first. Given a map, it goes through the map's keys. It works on a copy taken when the loop starts, so adding to or removing from the list inside the loop does not change which items it visits. Break out of loop stops it early.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | variable | The variable that holds the current item on each pass. |
| 2 | list | The list to go through, or a map to go through the keys of. |
Script: for item in list { }
break out of loop
Leaves the loop it is in straight away and carries on with the blocks below that loop. Outside a loop it does nothing.
Script: break
wait [number] ticks
Pauses this script, then carries on where it left off. 20 ticks are one second. The rest of the server keeps running meanwhile, and variables keep their values. It cannot be used inside a function whose result is used as a value.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | number | How long to wait, in ticks. 20 ticks are one second. |
Script: wait ticks
debug log [any value]
Writes a line to the server log, tagged with the script it came from. Nothing is shown in game. Use it to check what a value holds while a script runs.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | any value | What to write. Text, a number or any other value. |
Script: log value
end the game
Ends the game the way the other Merged games do: the server is taken off the Event Servers list, everyone is sent back to the lobby, and the server stops 5 seconds later. Show your winner messages before it. On a dev fragment it only reports that the game would end, so the fragment keeps running.
Script: endGame()
return
Stops the function it is in straight away and goes back to whoever called it. Outside a function, it stops the whole script for this event.
Script: return
return [any value]
Stops the function it is in and hands a value back, which becomes the result of the call. Outside a function, it stops the whole script for this event and the value is thrown away.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | any value | The value the function call should give back. |
Script: return value