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.
Document stub.png This article or section may not have content matching Scratch Wiki editing standards. Please improve it according to Scratch Wiki:Guidelines and Scratch Wiki:Editing Conventions. (August 2018)
Reason: Not really comprehensive, doesn't teach enough
Note Note: This is a tutorial on modding Scratch 1.4. If you want to mod Scratch 2.0, use this tutorial on the forums.

Although Scratch can seem complicated to some users, some Scratchers make Mods, or Modifications of the program to add more elements and blocks. Scratch was developed in Squeak, however one does not need Squeak installed to make your mod. The Squeak website is here.

Before You Begin

When creating a Scratch Modification, one would open the System Browser to edit and modify (often shortened to mod) the source code. The code is made up of classes and, within those, are methods.

Note Note: A class is not to be confused with the term CLASS. This will get into further detail later.

Before one makes a Scratch Modification, they must have the following:

Setting up your Mod's folder

As previously mentioned, One would edit the coding in the System Browser, and modify the classes and methods to add or change features

Note Warning: Modifying Scratch may result in loss of elements. When editing, be sure to use care; some classes/methods may not be possible to restore, so it is recommended that you back up your work every time you make any changes. If you make a big mistake in modding, it will "break" your mod and render it unusable.

The first step is to rename the Scratch Source Code folder, ScratchSkin folder (optional), and image file to your Mod's title. Make a new folder for your Mod, and put the Source Code folder and Scratch Skin folder in it (optional). Copy the "media" folder from the Scratch program folder to your mod's new folder and delete Gobo and the Scratch Cat.

Note Note: You will probably want to rename cat2 to cat1, cat3 to cat2 etc...

To edit the Source Code, simply open the file: "ScratchSourceCode[version]" with the Scratch application. Shift-click the File menu, choose "Exit user mode," click the white area that appears, choose "open...," and choose "browser." Select the box titled: "System Browser". This is basically the whole program in the Squeak language!

Editing the Source

There are 4 menus in the System Browser. Select "Scratch-Objects", then "ScratchSpriteMorph". Under that menu pane is 3 buttons: "instance", "?", and "class". Select "class". On the right is another menu. Select "block specs", then "blockSpecs".
Now you're ready to start adding blockSpecs! "BlockSpecs" are Block Specifications. They tell Squeak what content should be on a specific block.

For example, the blockSpec for

move (10) steps


('move %n steps' #- #forward:)
Note Note: This is what the blockSpecs look like in the Scratch System Browser. In the Source Code, the "#" are replaced with spaces.

2 quotes ('') define a "string". In between the quotes, goes the text. Any text is considered a "string". In the

move (10) steps

block, the string is this:

'move %n steps'

That makes

move (10) steps

have the title that it has.
You might be wondering, "What about the %n part?" %n is the number input. It allows users to type a number into a box. Let's look again at the #- part. That defines that it's a stack block. There are different Block Types, and in each blockSpec, that part is important. For a reporter block, r is used. For a boolean block, b is used. The forward: part calls the method, "forward:". The "method" is the actual code that the block uses to function. The

move (10) steps

block has a method titled "forward:", and is the following:

forward: distance
	"Move the object forward (i.e., the direction of its heading) by the given distance.
	Avoid infinite or NaN coordinates"

	| radians deltaP newPos newX newY |
	radians _ rotationDegrees degreesToRadians.
	deltaP _ ((radians cos)@(radians sin)) * distance.
	newPos _ self position + deltaP.
	newX _ newPos x.
	newY _ newPos y.
	newX isNaN ifTrue: [newX _ 0].
	newX isInf ifTrue: [newX _ newX sign * 10000].
	newY isNaN ifTrue: [newY _ 0].
	newY isInf ifTrue: [newY _ newY sign * 10000].
	self position: newX @ newY.
	self keepOnScreen.

The first "distance" is a "variable". It is defined by the input. The rest of the method is more advanced, but that is only because the block is more advanced than some others. This block seems very simple, but when you know how Scratch does it, you'll see why! See the block workaround for it.


This so far has been just the basics of Squeak. You can learn more coding by reading the Squeak Tutorial. You can also go to this FAQ topic.

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