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.
Note Warning: 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

  1. Create your project.
  2. Make a personal variable called "variable".
  3. 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 or if this is tested on Scratch 2.0, it may just say "Infinity", and not close.

Method 2: Graphic Effects

  1. Get into the Scratch 1.4 Source Code and open the System Browser.
  2. Add 'water ripple' near the rest of the graphic effect names in Scratch-Objects >> ScriptableScratchMorph instance >> looks ops >> graphicEffectNames
  3. Save your changes and close the System Browser.
  4. 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

  1. Get into the Scratch 1.4 Source Code and open the System Browser.
  2. In Scratch-Objects >> ScriptableScratchMorph class >> block specs >> blockSpecs add ('close Scratch' #- #closeScratch) at the end of the 'control' section
  3. Add the following in Scratch-Objects >> ScriptableScratchMorph instance >> other ops
closeScratch
	Smalltalk snapshot: false andQuit: true
  1. Save both your changes and close the System Browser.
  2. 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 ::control

References

  1. http://scratch.mit.edu/projects/1504686 / http://scratch.mit.edu/static/projects/rubiks_cube_guy238/1504686.sb