Again and again
ReadingDoing it again
Say you want a slime to jump three times. You could write it like this.
when I start
jump
wait 1 second
jump
wait 1 second
jump
wait 1 secondIt works. But it is long, and if you want ten jumps it gets silly. There is a better way.
A loop
A loop does the same steps again and again. In Splat Script, a loop starts with repeat.
when I start
repeat 3 times
jump
wait 1 second
endThis does just the same thing, in fewer lines. To get ten jumps, you change one number.
The parts of a loop
| Part | What it does |
|---|---|
repeat 3 times | Starts the loop, and says how many times to go round. |
| The steps inside | Pushed in under the repeat line. These are done each time round. |
end | Shows where the loop stops. |
Three kinds of loop
| Loop | How long it goes on |
|---|---|
repeat 3 times | A set number of times. From 1 to 20. |
repeat forever | It never stops by itself. |
repeat until the {Hero} is near | Until the answer to a question is yes. |
Finish this section
Tick Finished reading at the bottom of the page. Then press Next to try each kind.

