(Redirected from Procedures)

"Custom Block" redirects here. For the block itself, see () (Custom block).
SandCastleIcon.png This page has links to websites or programs not trusted by Scratch or hosted by Wikipedia. Remember to stay safe while using the Internet, as we can't guarantee the safety of other websites.
define custom block
The define block in Scratch 3.0.
My Blocks (known as More Blocks in Scratch 2.0) is one of the ten categories of Scratch blocks. It holds procedures for the selected sprite. They are color-coded pink. Before any blocks are created, it is empty, except for a "Make a Block" button. Clicking this button brings up a dialogue asking for the block name. Then, enter the desired name as well as any inputs, and create the block.
A define block from More Blocks in Scratch 2.0
The past versions of the Define block

This category can technically have an unlimited amount of blocks, due to its blocks being user-created, but it has 1 type of Stack block and 1 type of Hat block (albeit modified).

Blocks

Note Note: Click on a block to learn more about it!

Scratch 3.0 has the following 1 Hat block in More Blocks:

Scratch 3.0 has the following 1 Stack block in More Blocks:

Uses of Custom Blocks

Custom blocks are useful in many programming situations, such as the following:

  • reduced project file size
  • running a script without screen refresh
  • organization of scripts instead of duplicating large scripts with minor edits

Custom blocks allow for number, string, and Boolean inputs to be inserted into the definition and title, which the input of can be edited in the stack block. For example, if you have a number input inserted into a custom block's definition, you can run the custom procedure entering any number into the custom stack block, and that number will be rendered as all the number inputs in the definition. This easy input insertion method allows a project to perform large, customizable scripts without having to duplicate the scripts, edit a few blocks, and waste file space. This block is used because if you have a bunchload of scripts, and you need to repeat them a bunchload of times, more blocks saves time for that. Also, there is a button called 'Run without screen refresh' which can be used to make things happen faster.

Using custom blocks is the only way to run scripts without screen refresh. Screen refresh is the very miniscule wait between each block in a script. When creating the title of a custom block, there is an edit menu with the input insertions and also a checkbox that allows you to disable screen refresh (by default it is enabled.) When the box is checked and the custom block runs, it will perform in an instant, which can be beneficial for setting up a particular scene in a project or performing large mathematical calculations, possibly in a game with artificial intelligence.

Also, when making a new block, you may notice an options section under the block that you have created:

The Make a Block dialog.

This block is used because if you have a lot of scripts, and you need to repeat them a lot of times, more blocks saves time for that. Also, there is a button called 'Run without screen refresh' which can be used to make things happen faster.

Workaround

Main article: List of Block Workarounds

The workaround for custom blocks does not allow features such as inputs, for they would require variables, or disabling screen refresh, but it works well for basic scripts. It uses a broadcasting method instead of a procedure. When the broadcast is received, in a way the sprite or stage performs its own procedure.

when gf clicked
broadcast [jump v] and wait
when I receive [jump v]
repeat (5)
change y by (6)
end
repeat (5)
change y by (-6)
end

Procedures in BYOB/Snap!

Snap!, previously called BYOB (Build Your Own Blocks), is a Scratch modification that allows procedures. Snap!'s procedures allow all 3 types of blocks, with arguments, and also recursion.

Common Suggestions

Document.png Please expand this article or section. You can help by adding more information if you are an editor. More information might be found in a section of the talk page. (April 2019)

Many Scratchers would like My Blocks reporters or boolean blocks. Additionally, dropdown inputs as arguments have also been requested, to the extent that some people used JSON hacking to insert them into custom blocks.[1].

References

  1. topic:20661

See Also