(Redirected from Cap Blocks)
There are two Cap blocks, both located in the Control category:
- Stop () — stops either everything, the script, or all other scripts in the sprite. If "other scripts in sprite" is selected, it becomes a stack block.
- Delete This Clone — stops all the scripts that the clone is running and deletes the clone
As Cap blocks are designed to stop a script or project, their bottom is smooth so that no blocks can be placed under them, as there is no need. Other than that, their shape is identical to the Stack block — they still have the notch on the top so the block can be placed below others.
Making a Cap Block
The coding in the System Browser blockspecs for a cap block is the same as a stack block. To make the bottom smooth, the method at the location
Scratch-Blocks >> CommandBlockMorph >> accessing >> isStop must be edited. Add:
| (selector = #method)
The need to stop a script (or all scripts) can be found in several occasions. Some include:
- Disabling a script that will continuously set a variable
- Once a game is completed, all scripts stop
- Deactivating a sprite
An example that stops the script if the letter z is in in
set [Letter v] to  repeat (length of (answer)) change [Letter v] by (1) if <(letter (Letter) of (answer)) = [z]> then stop [this script v] end end
Note how the Cap block (Stop ()) is used — if the selected letter is "z", the script stops.