From Test-Scratch-Wiki

Archive.png This article or section documents a feature 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 itwas confined to its script and did not deactivate all scripts in the project.

Before version 1.2, the block was a stack block.

This block became obsolete with the release of Scratch 2.0 and the introduction of the stop () 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>
. . .
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>
stop script
end
. . .
if <I should stop>
stop script
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] = [-1]> // the condition will never be met, thus making the script wait forever

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

See Also

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