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.

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.

The system browser opened to blockSpecs method.

Navigating to Block Specs

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
  • f — Math function menu (with sin, abs, etc.)
  • 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
  • LList name menu
  • n — Numerical insert
  • N — Note name menu/insert
  • SSound selector menu

List of identifiers:

  • 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

Note 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.
Cookies help us deliver our services. By using our services, you agree to our use of cookies.