List of Blocks
There are three Cap blocks, all located in the Control category.
|Note:||Click on a block for more information.|
stop [ v]— 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.
forever— Loops the script inside forever until the stop sign is clicked.
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
|This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective.|
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.