From Test-Scratch-Wiki
- This article or section documents an outdated version of Scratch (version 1.4). For this article in Scratch 2.0, see Eng:Making Scratch Close (2.0).
![]() | This script will close Scratch without saving your work. Be sure to save before testing this. |
It is simple to make a project that closes when the Green Flag is clicked. This has been one way users try to prevent remixing, though it is actively discouraged by the Scratch Team. It has also not been successful, as you can open a remixed project without ever pressing the Green Flag.
Method 1: Variables
- Create your project.
- Make a personal variable called "variable".
- Add the following code to your sprite:
when gf clicked hide set [variable v] to [2] repeat (variable) set [variable v] to ((variable) * (variable)) repeat (variable) set [variable v] to ((variable) * (variable)) end end
Or
when gf clicked hide set [variable v] to [2] repeat (variable) change [variable v] by ([10 ^ v] of (variable)) repeat (variable) change [variable v] by ([10 ^ v] of (variable)) end end
Or
when gf clicked hide set [variable v] to [12] forever set [variable v] to ((variable) * (variable))
Explanation
This script will fill Squeak's memory, and will force it to close. Squeak automatically crashes when a variable reaches a very high amount as it does not have the memory to maintain it. Since Scratch runs within the Squeak environment, Scratch closes when the Squeak environment closes. If a high RAM has been allotted to Scratch, it may just say "Infinity", and not close.
Method 2: Graphic Effects
- Get into the Scratch 1.4 Source Code and open the System Browser.
- Add
'water ripple'
near the rest of the graphic effect names inScratch-Objects >> ScriptableScratchMorph instance >> looks ops >> graphicEffectNames
- Save your changes and close the System Browser.
- Drag out a Set () Effect to () block and choose "water ripple" from the dropdown and set the value to 1 or higher. When the block is clicked, it will crash Scratch. Note that Squeak doesn't have enough memory to run the effect, so it crashes instead.[1]
when gf clicked set [water ripple v] effect to (1)
Method 3: Hacked Block
- Get into the Scratch 1.4 Source Code and open the System Browser.
- In
Scratch-Objects >> ScriptableScratchMorph class >> block specs >> blockSpecs
add('close Scratch' #- #closeScratch)
at the end of the'control'
section - Add the following in
Scratch-Objects >> ScriptableScratchMorph instance >> other ops
closeScratch Smalltalk snapshot: false andQuit: true
- Save both your changes and close the System Browser.
- Drag out the close Scratch block that you just made, and run the block. Instead of crashing, Scratch closes without a warning.
when gf clicked close Scratch // category=control