Designing Custom Blocks
From Observation Notes Analysis:
- U1L4 (now seemingly moved here): "The Build House mini-project was hard for at least one student who said that building their own blocks was the problem there."
- U3L4 (seemed more relevant here now): "… idea of building special-purpose blocks --- the abstraction thing --- is hard….kids' calculations tend for a long time to be "spaghetti code." The TG doesn't suggest anything to help the teacher clarify what the problem is before students start working on it…"
So far, you've used blocks that already existed. Now, you'll learn to build your own blocks and use them to make other blocks.
You'll start by defining a draw square
block with a familiar script (shown right). Then, you'll define draw triangle
, then draw house
, and finally draw row of houses
.
Creating a block gives a
name to a script that can be called inside another block. This is a form of
abstraction, tucking away the details of your code to make the overall structure clearer and easier to debug. Soon, you'll learn how to
give your script an input, just as

takes an input to tell the sprite how far to move.
"U1L3-Polygons"
-
To get the Block Editor, you can also click

near the bottom of the Variables palette.
Build the draw square
block: right-click (or, on a Mac, control-click) on the gray background of the scripting area and choose "make a block..."
- The video below shows the first few steps. Finish it yourself, and press OK or Apply.
- More details about defining blocks are in the big yellow section below.
![make a block]()
-
Find your block at the bottom of the palette you chose when you defined it. If you created the block as a Motion block, you will find it in the Motion palette. (If you didn't choose a palette, it will be in with Variables.)
Test your draw square
block, using it the same way you've used other blocks. Fix your code if necessary.

Congratulations! You have just created your first custom block.
Every block needs a place to "live" (a
palette, shown by the color), a
title, a
category (shown by the shape of the block), and a
script that defines its behavior.
-
You can put the new block in any palette that makes sense to you. If you don't choose a palette/color, your block will be a gray "Other" block and will be sorted into the "Variables" tab.
Palette: Choose a palette for your new block to go into. ("Motion" or "Pen" might be appropriate for the draw square
block.)
-
Title: Give your block a name. For this block, type "draw square" as shown here.
-
Category: Leave "Command" selected since this block performs an action (drawing a square) rather than reporting a value.
- For all sprites.
In this course, you will almost always want to keep "for all sprites" selected, so you can ignore that choice for now, and click "OK".
-
Behavior: A dialog titled "Block Editor" will appear. Build the instructions for your new block here just as you do in the scripting area. Drag blocks from the palette to define the script that will run when your custom block is used. When you are finished, click OK or Apply.
The editor starts you with a hat block that contains a picture of your block. Remember that hat blocks say when the script below them should run:
when flag clicked
,
when space key pressed
, etc. This hat block says, "when the
draw square
block is used." (Don't worry about the
+ signs for the moment; they just let you add more words or
inputs.)