(Redirected from Hat)
This article has links to websites or programs outside of Scratch and Wikipedia. Remember to stay safe while using the internet, as we cannot guarantee the safety of other websites. |
A Hat Block is a block that starts a script when a specific event occurs. All hat blocks are either Control blocks, Events blocks, My Blocks, or Extension blocks. In the Experimental Viewer, the first word of their name is capitalised.
Hat blocks are useful in Event Based Programming.
Shape
As Hat blocks are designed to start a script, they are shaped so no blocks can go on top of them — this is done by rounding the blocks' top. The bottom of Hat blocks are the same as Stack Blocks.
when gf clicked//This is a hat block. go to (mouse-pointer v)
Blocks
There are twenty-six Hat blocks in Scratch. Seventeen are used for extensions. One is made with every instance of a custom block.
Note: | Click on a block for more information. |
when gf clicked
when [ v] key pressed
when this sprite clicked
when stage clicked
when I receive [ v]
when backdrop switches to [ v]
when [ v] \> ()
when I start as a clone
define
when video motion > ()
when ( v) key pressed::makeymakey
when ( v) pressed in order
when ( v) button pressed::microbit
when ( v)::microbit
when tilted ( v)::microbit
when pin ( v) connected::microbit
when button ( v) pressed
when distance \< ()
when brightness \< ()
when ( v) brick seen
when tilted ( v)
when distance ( v) ()::wedo
when tilted ( v)::wedo
when ( v)::gdxfor
when force sensor ( v)::gdxfor
when ( v)::gdxfor
When () is True
when <> is true :: hat events
A heavily-requested hat block is When () Is True.[1] It was available in the November 2006 beta but was removed in Scratch 1.0. It is available in some Scratch Modifications. This block can be reproduced by doing the following:
when gf clicked forever wait until <... :: grey> broadcast (true v) wait until <not <... :: grey>> when I receive [true v] ...
or
when gf clicked forever if <... :: grey> then end
The latter is equivalent to the replacement in Scratch 1.0.
Use
Hat blocks signal for the project to run a script after an event has happened, and therefore allows the code to be run automatically without a user having to click on the script to run the code. As there are 24 Hat blocks, there are 24 different forms of events that can occur to start a script.
An example for when the When I Receive () block can be used as follows:
when I receive [Next Level v] next costume
Cat Blocks
- Main article: Cat Block
when green flag clicked:: cat when this sprite clicked:: cat when I start as a clone:: cat when video motion > ():: cat
For April Fools Day 2020 and for April fools 2021, 2022 and 2023, all hat blocks were replaced with 'Cat Blocks' for 2022 and 2023 Caturday mode had to be enabled, where a cat drawing was put on top of them. Rolling the mouse over near the eyes of the cat block would cause its eyes to blink, and mousing over its ear would cause the ear to move.
There were many requests to bring them back,[2][3] but it was officially rejected by the Scratch Team.[4] However, they can still be accessed here.
References
- ↑ Dankuk. (28/5/2015). "A ‘When True’ Block" topic:119900
- ↑ studios:26168823
- ↑ studios:26193966
- ↑ Za-Chary. (2/4/2020). "Unfortunately, this suggestion has been rejected recently." post:3909655