Control blocks
Control blocks decide when and how often other blocks run: loops, conditionals, waiting, stopping, and clones. Several of them are C blocks that wrap the blocks placed inside.
Waiting
- wait
1seconds pauses the script for a time. - wait until
<condition>pauses until a boolean becomes true.
Loops
- repeat
10runs the wrapped blocks a set number of times. - forever runs the wrapped blocks endlessly (a cap block, nothing follows it).
- repeat until
<condition>runs the wrapped blocks until the boolean becomes true.
Conditionals
- if
<condition>then runs the wrapped blocks only when the boolean is true. - if
<condition>then ... else runs the first branch when true, the second when false.
Stopping and clones
- stop
all/this script/other scripts in spritehalts scripts.allstops the whole project. - when I start as a clone (hat) runs when a clone of this sprite is created.
- create clone of
myself/ sprite makes a running copy of a sprite. - delete this clone removes the clone running this script (a cap block).
Bilup and TurboWarp extras
These control blocks are not in stock Scratch's palette:
- while
<condition>runs the wrapped blocks as long as the boolean stays true (the opposite ofrepeat until). - for each
itemin10runs the wrapped blocks once per count, setting a variable to 1, 2, 3, and so on. - all at once runs the wrapped blocks without any screen-refresh yielding, in one frame. It is kept mainly for compatibility; a normal script under warp behaves the same way.
- switch
expression, casevalue, default, and break build a switch statement: the matchingcasebranch runs, and plain cases stop at the next case (no fall-through unless you addbreakbehaviour). See Bilup extras for details. - counter, increment counter, and set counter to
0are a lightweight built-in counter carried over from Scratch 2 (reporter, stack, and reset). They avoid needing a variable for simple counting.