We are going to teach the computer how to draw a square using a block
draw square. Please follow the steps below:
make a block at the bottom of the
(or right-click or control-click on the scripting area background and choose "
make a block").
This will open up the
Make a block dialog box. There are several
steps that you'll do here, corresponding to each
area of the dialog.
Now, you get to choose which tab the block should go into.
Our block is going to draw a square, so let us choose
(Note: A very common mistake is to omit this step. If you do forget,
your block will become a gray Other block, in the Variables palette.)
First, at the top of the dialog, you should select in which palette the block will
be place. This block is going to draw a square, so choose
Motion tab should highlight in blue, as in the picture below.
Second, you'll want to enter a title for the block in the edit field.
draw square, which should show up as in the picture below.
Third, you have the option of making blocks of different shapes,
corresponding to the
Predicate icons. By default the
Command icon is
selected, and this is the one you want. (You will learn about
the other shapes of custom blocks in the next topic).
Fourth, there are two radio buttons that you can safely ignore. You will
almost always want to keep
for all sprites selected in this course.
After you click
OK, a dialog titled
you will see a specially shaped block with the title of the
custom block that you are creating. This kind of block is
called a "hat" block, and it indicates a starting place for the
draw square script.
You can treat this dialog like you do the scripting area of the main Snap! window. Drag blocks here from the palette to define the script that will run when your custom block is used.
Use the blocks from the Control and Motion palettes to create a script that draws a square, as shown below.
When you click
OK, you should be able to use this block as if it
were a regular block. Since you created the block as a
block, it will end up at the bottom of the
Congratulations! You have just created your first custom block.