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. For information on the feature that replaced this one, see Stop () (block).
Stop Script
Stop Script.png
Category Control
Type Cap
Introduced in 1.0
Removed in 2.0

The Stop Script block was a Control block and a Cap block. The block would deactivate its script, stopping it completely. This block worked similar to the Stop All block, except that it was confined to its script and did not deactivate all scripts in the project.

Before version 1.2, the block was a stack block. Before 1.0, this block was called Done, along with another block with the same function in 0.1 and 0.2. This block became obsolete with the release of Scratch 2.0 and the introduction of the stop () block.

text
The history of the stop script block.

Workaround

Main article: List of Block Workarounds

The "Stop Script" was most often used to stop loops (especially "forever" and "forever if" loops). A common work around is to use a "Repeat Until" loop instead.

repeat until <condition that should stop script::operators>
. . .
end

However, such a work around is not perfect. The primary advantage of the "Stop Script" is its ability to be used throughout the loop. For loops that are lengthy, one often wants to stop the script as quickly as possible, rather than waiting for the script to loop back through the conditional. This is easily done with the "Stop Script" block within an If () Then (block). For instance, the following script has a faster "reaction time" to an event that demands the script be stopped than the one above.

forever
. . .
if <I should stop::operators> then
stop script :: control
end
. . .
if <I should stop::operators> then
stop script :: control
end

The following workaround pauses the script at one point forever, rather than stopping the script, but can still be used to prevent code from being activated.

when gf clicked
. . .
wait until <[1] = [0]> // the condition will never be met, thus making the script wait forever

Or for a simple one-block method in 2.0:

stop [this script v]

Example Uses

As this block will stop its script, it is widely used when an action performed by a script must cease. Some common uses:

  • Disabling controls
forever
  if <(ammunition) < [1]> then
    set [active v] to [0]
    stop script :: control
  else
    set [active v] to [1]
  end
  • Only performing an action once, and then stopping
forever if <(loss) = [1]> :: control cstart
    broadcast [failure v]
    stop script :: control
end
  • Depending on a variable, if an action is performed or the script canceled
when I receive [Show v]
switch costume to [costume1 v]
if <(allow) = [1]> then
 go to x: (0) y: (0)
else
 stop script :: control
end
broadcast [Ready! v]

See Also