Eng:Stop Script (block)

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
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  . . . 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  stop script end . . . if  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: forever if <(ammunition) < [1]> set [active v] to [0] stop script else set [active v] to [1] end forever if <(loss) = [1]> broadcast [failure v]   stop script
 * Disabling controls
 * Only performing an action once, and then stopping
 * 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]