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 second

It 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
  end

This does just the same thing, in fewer lines. To get ten jumps, you change one number.

The parts of a loop

PartWhat it does
repeat 3 timesStarts the loop, and says how many times to go round.
The steps insidePushed in under the repeat line. These are done each time round.
endShows where the loop stops.

Three kinds of loop

LoopHow long it goes on
repeat 3 timesA set number of times. From 1 to 20.
repeat foreverIt never stops by itself.
repeat until the {Hero} is nearUntil 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.