(Redirected from Cap Blocks)

The general shape of a Cap block.

A cap block is a block that is designed to stop a block from being placed underneath it. It looks and acts like a Stack Block, except there is no bump underneath it and blocks cannot be placed under it.

List of Blocks

There are three Cap blocks, all located in the Control category.

Note 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. This block is also a C Block.

Shape

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

Archive.png 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)
and accept.

Uses

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 (answer):

ask (...) and wait
if <(answer) contains [z]> then
stop [this script v]
end

Note how the cap block (Stop ()) is used — if the answer contains "z", the script stops.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.