From Test-Scratch-Wiki
![]() |
It has been suggested that this page's contents be merged with the page Custom Blocks. You can discuss this on the page's talk page. |
What is a Custom Block?
A Custom Block is a block that the user creates. You can use other pre-programmed blocks like the
move () steps
block within your Custom Block definition.
How Do You Make a Custom Block?
To make a Custom Block, you must go into the More Blocks section in the scripting editor, and click Make a Block. When you do so, a small window will pop up and have an area area where you can type something in. What you type in will be the name of your block. If you click the Options drop down, you'll see some fancy things, which this page will walk you through later. Ignore those for now, and click OK.
How to make a block do something
When you click OK, in the scripting area there will be something that looks like
define block
To program the block, add normal scripts like the following:
define block move (10) steps say [Hello!] go to [mouse-pointer v] . . .
Once you have the definition done, you can drag the new block from under the "more blocks" category and use it! It will do what is under the "Define" block.
What Are Those Input Options?
When you are creating a block and you click on the options drop down menu, you will see a menu that gives you the ability to add parameters to your block like a Boolean slot, a numeric input, or a string input. If you look at the bottom, you'll see a little checkmark box that says "run without a screen refresh," which makes the block run in Turbo mode The "Add Text Label" is useful for adding text after you make a slot, which can be done by clicking on one of the buttons on the far right. Click All of the buttons, and click OK so you get something that looks like:
define block (number1) [string1] <boolean1> text
When you start scripting the block, you put the slot icons in their actual slots like:
define block (number1) [string1] <boolean1> text repeat until (boolean1) say (string1) for (number1) secs end
The blocks that look like reporter blocks are variables that can be used as parameters in running the 'block' function. When calling a define block from another script, values can be entered in these blocks as values.
This function opens up a whole new amount of possibilities! If you can figure out how to store a list in a variable, you can use a block that says
define save [tobesaved]
to make it easier for fellow scratchers to understand your work. It could also help you!