This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective. |
Blockmaking is the practice of creating customized Scratch blocks, often for Scratch Modifications. This page lists FAQs about it.
Difficulty of blockmaking
The difficulty depends on what is wanted to be done. There are blockspecs and methods. The blockspecs are what define the block itself. The methods tell the block what to do.
Do I need any other programs?
All you need is Scratch or the Source Code. However, if you are having trouble, Scramble is a good way of getting started. You need to program in Squeak. A good way to start with Squeak is with Squeak Tutorial on this Wiki.
Making a Block
Squeak is sometimes hard to get the hang of, so you can get the code for some custom blocks at the Block Library.
Open the System Browser. From the browser, go to:
- Scratch-Objects
- ScriptableScratchMorph
- Click onto Class
- block specs
- blockSpecs
Adding the Block Spec
The block spec for each block is in brackets and uses the following structure:
('block text' #identifier #selector 'default' 'values')
Inputs are put the block text where desired. Each input has a %
followed by a letter representing the input type.
List of inputs:
a
— Attribute of another sprite, such as X position or size
b
— A boolean insert
c
— Color picker that shows the menu
C
— Color picker that does not
d
— The sprite direction menu/numerical insert
D
— The menu for MIDI drums
e
— The broadcast message menu
f
— Math function menu (with sin, abs, etc.)
g
— Menu for the different graphic effects
h
— Numerical sensor board selector menu
H
— Boolean sensor board selector menu
i
— MIDI instrument menu/numerical insert
k
— Menu for the names of the different keys
l
— Menu with the costume names of the current sprite
L
— List name menu
m
— Sprite list
n
— Numerical insert
N
— Note name menu/insert
s
— String insert
S
— Sound selector menu
v
— Variable menu
y
— Menu in Delete () of ()
List of identifiers:
-
— Stack Block
r
— Reporter Block
b
— Boolean Block
c
— C Block
t
— Time block (such as Wait () Secs)
W
— 'When' Hat Block (obsolete)
S
— When Green Flag Clicked block
K
— When () Key Pressed block
E
— When I Receive () block
s
— Special form (hard to code)
For example, the blockspec for the repeat block is:
('repeat %n' #c #doRepeat 10)
When you are done, right-click in the System Browser and click accept.
Adding the Code
Click 'instance' (next to class). Then click the appropriate 'op'. Add the code and command for the block. Right click and click accept.
Saving the Image
Caution: | Saving your Scratch image can only be undone by re-installing Scratch. |
Close the system browser. You may now test your new block. When you are done Shift-Click-R and click 'Save image for end user'. This will save your changes to Scratch.
Notes
- When modifying Scratch like this, It is a good idea to install two versions of Scratch, each in a different directory, in case something goes wrong. If something does go wrong and there aren't two different versions, Scratch can always be reinstalled.
- Better yet, the source code of Scratch should be downloaded which can be edited separately. The changes can be distributed as a Scratch Modification.