Custom Blocks (My Blocks)
When you find yourself building the same group of blocks again and again, you can make your very own block instead. In Scratch these are called My Blocks, and they live in the pink My Blocks category. Making your own block is like inventing a new command that does exactly what you want.
Creating a custom block
Click Make a Block. A window pops up where you type a name, such as draw square or jump. When you click OK, two things appear. First, a define hat block shows up in your scripts area. Second, your new block appears in the My Blocks palette, ready to drag out.
You put the instructions you want under the define block. From then on, every time you use your new block, Scratch runs everything under its define. This is called calling the block.
Inputs make blocks flexible
When you make a block, you can add inputs. An input is a little slot you fill in each time, like a number or some text. For example, a jump block could have a number input for how high to jump. Inside the define, you drag the input name into the blocks that need it. Now one block can do many different jumps.
Why custom blocks are great
- They keep your scripts short and tidy.
- They let you reuse the same idea in many places without copying.
- If you need to fix something, you only change it once inside the define.
- They give your code clear names, so it reads almost like a sentence.
Run without screen refresh
In the Make a Block window there is a checkbox called Run without screen refresh. Tick it when you want the whole block to finish instantly, which is very handy for drawing shapes with the pen so they appear all at once.
Custom blocks are how big projects stay simple. Break a hard job into small named blocks, and your project becomes much easier to understand and to grow.