![]() |
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. |
- This article is about the programming blocks. For other uses, see Blocks (disambiguation).
Blocks are puzzle-piece shapes that are used to create code in Scratch. The blocks connect to each other vertically like a jigsaw puzzle, where each data type (hat, stack, reporter, boolean, or cap) has its own shape and a specially shaped slot for it to be inserted into, which prevents syntax errors. Series of connected blocks are called scripts.
There are ten categories of blocks: Motion, Looks, Sound, List, Event, Control, Sensing, Operators, Variables, and My Blocks. Only nine of these are shown in the Block Palette.
In total, there are seven Hat Blocks, five C Blocks, thirty-one Reporter Blocks, thirteen Boolean Blocks, two Cap Blocks and fifty-nine Stack Blocks.![]() | Block numbers do not include extensions. |
Contents
Block Shapes
There are six different block shapes: Hat, Stack, Boolean, Reporter, C and Cap.
Hat blocks
- Main article: Hat Block
Hat blocks are the blocks that start every script. They are shaped with a rounded top and a bump at the bottom — this is so you can only place blocks below them. There are 11 Hat blocks in the Scratch editor, six of which are in the Events category, one in the Control category, and one in the category My Blocks (if one has created one custom block).
Stack blocks
- Main article: Stack Block
Stack blocks are the blocks that perform the main commands. They are shaped with a notch at the top and a bump on the bottom — this is so blocks can be placed above and below them. There are 77 Stack blocks — the most common block shape.
Boolean blocks
- Main article: Boolean Block
Boolean blocks are the conditions — they are either true or false. For example, asking a computer: "Does 2 + 2 = 4?", and it would either tell you "Yes" or "No". With a hexagonal shape, there are 13 of these blocks.
Reporter blocks
- Main article: Reporter Block
Reporter blocks are the values. Reporter blocks can hold numbers and strings. It is like asking a friend, for example, "What is 2 + 2?", and they would answer "4". It can also report a variable. For example, "What is your age?" and they may answer: "15". Shaped with rounded edges, there are 37 of these blocks — not counting the theoretically infinite amount of Reporter blocks that can be made for each variable and list.
C blocks
- Main article: C Block
C blocks are blocks that take the shape of "C's". Also known as "Wrap blocks", these blocks loop the blocks within the Cs or check if a condition is true. There are five C blocks, and they can be found in the Control category. C blocks can be bumped at the bottom, or capped.
Cap blocks
- Main article: Cap Block
Cap blocks are the blocks that end scripts. They are shaped with a notch at the top and a flat bottom — this is so you cannot place any blocks below them. There are two Cap blocks which can both be found in the Control category.
List of Blocks
There are 119 blocks in Scratch 3.0 (not including extensions):
Motion blocks
- Main article: Motion Blocks
Motion blocks are the blocks that control a sprite's movement. There are 17 Motion blocks in Scratch 3.0.
Scratch 3.0 has the following fifteen Motion Stack blocks:
-
move () steps
— Moves the sprite forward the number of steps in the direction the sprite is facing. -
turn cw () degrees
— Turns the sprite (clockwise) the specified amount. -
turn ccw () degrees
— Turns the sprite (counter-clockwise) the specified amount. -
point in direction ()
— Points the sprite in the direction. -
point towards [ v]
— Points the sprite towards the mouse-pointer or another sprite. -
go to x: () y: ()
— Moves the sprite to the specified X and Y position. -
go to [ v]
— Moves the sprite to the mouse-pointer, a random position, or another sprite. -
glide () secs to x: () y: ()
— Glides the sprite to the location, taking as long as the specified amount of time. -
glide () secs to [ v]
— Glides the sprite to the mouse-pointer, a random position, or another sprite, taking as long as the specified amount of time -
change x by ()
— Changes the sprite's X position by the amount. -
set x to ()
— Sets the sprite's X position to the specified amount. -
change y by ()
— Changes the sprite's Y position by the specified amount. -
set y to ()
— Sets the sprite's Y position to the amount. -
if on edge, bounce
— If touching the edge of the screen, the sprite's direction flips over -
set rotation style [ v]
— This sets the rotation style of a sprite.
Scratch 3.0 has the following three Motion Reporter blocks:
-
(x position)
— The X position of the sprite. -
(y position)
— The Y position of the sprite. -
(direction)
— The direction of the sprite.
Looks blocks
- Main article: Looks Blocks
Looks blocks are the blocks that control a sprite's look. There are 23 Looks blocks in Scratch 3.0. Three of the 19 sprite Looks blocks have a counterpart for the Stage.
Scratch 3.0 has the following eighteen Looks Stack blocks:
-
say [] for () secs
— A speech bubble appears over the sprite and stays for the specified amount of time. -
say []
— A speech bubble appears over the sprite and will not go away over time. -
think [] for () secs
— A thought bubble appears over the sprite and stays for the specified amount of time. -
think []
— A thought bubble appears over the sprite and will not go away over time. -
show
— Shows the sprite. -
hide
— Hides the sprite. -
switch costume to [ v]
andswitch backdrop to [ v]
— Changes the sprite's/Stage's costume/backdrop to the specified one. -
switch backdrop to [ v] and wait
— Like the Switch to Backdrop () block, though it waits until all of the hat blocks triggered by this have completed. (Stage only) -
next costume
andnext backdrop
— Changes the sprite's/Stage's costume/backdrop to the next one in the costume list. -
change [ v] effect by ()
— Changes the specified effect by the amount. -
set [ v] effect to ()
— Sets the specified effect to the amount. -
clear graphic effects
— Clears all graphic effects on the sprite. -
change size by ()
— Changes the sprite's size by the amount. -
set size to ()%
— Sets the sprite's size to the amount. -
go to [ v] layer
— Puts a sprite in the front or back. -
go [ v] () layers
— Changes the sprite's layer value by the amount.
Scratch 3.0 has the following three Looks Reporter blocks:
-
(costume [ v])
and(backdrop [ v])
— The number or name of the sprite/Stage's current costume/backdrop in the list. -
(size)
— The sprite's size.
Sound blocks
- Main article: Sound Blocks
Sound blocks are the blocks that control sound and MIDI functions. There are 16 Sound blocks in Scratch 3.0.
Scratch 3.0 has the following eight Sound Stack blocks:
-
start sound [ v]
— Plays a sound without pausing the script. -
play sound [ v] until done
— Plays a sound and pauses the script until it finishes. -
stop all sounds
— Stops all playing sounds. -
change volume by ()
— Changes the volume by the amount. -
set volume to ()%
— Sets the volume to the amount. -
change [pitch v] effect by ()
— Change the pan left/right or pitch by the amount. -
set [pan left/right v] effect to ()
— Set the pan left/right or pitch to the amount. -
clear sound effects
— Clears any sound effects currently in place.
Scratch 3.0 has the following Sound Reporter block:
-
(volume)
— The volume.
Data blocks
Variables blocks
- Main article: Variables Blocks
Variables blocks are the blocks that hold values and strings. There are 5 Variables blocks in Scratch 3.0.
Scratch 3.0 has the following four Variables Stack blocks:
-
set [ v] to ()
— Sets the specified variable to the amount. -
change [ v] by ()
— Changes the specified variable by the amount. -
show variable [ v]
— Shows the variable's Stage Monitor. -
hide variable [ v]
— Hides the variable's Stage Monitor.
Scratch 3.0 has the following Variables Reporter block:
-
(variable)
— The variable's value.
List blocks
- Main article: List Blocks
List blocks are the blocks that manage lists. They are stored in the Data category. There are 11 List blocks in Scratch 3.0.
Scratch 3.0 has the following six List Stack blocks:
-
add [] to [ v]
— Adds an item to the list (the item goes at the bottom of the list of items) with the specified content in it. -
delete () of [ v]
— Deletes the item of the list. -
delete all of [ v]
— Deletes all items of the list. -
insert [] at () of [ v]
— Adds an item to the list (the item goes where you specify in the list of items) with the specified content in it. -
replace item () of [ v] with []
— Replaces the item's content with the specified content. -
show list [ v]
— Shows a list. -
hide list [ v]
— Hides a list.
Scratch 3.0 has the following 4 List Reporter blocks:
-
(list::list)
— The list's value. -
(item () of [ v])
— The item's value. -
(length of [ v])
— How many items there are in the specified list. -
(item # of [] in [ v])
— Reports the index in a list where an item first appears.
Scratch 3.0 has the following List Boolean block:
-
<[ v] contains []?>
— The condition for checking if an item's content is the specified text.
Event blocks
- Main article: Events Blocks
Event blocks are blocks that control events and the triggering of scripts. There are 8 Event blocks in Scratch 3.0.
Scratch 3.0 has the following six Event Hat Blocks:
-
when green flag clicked
— When the flag is clicked, the script activates. -
when [ v] key pressed
— When the specified key is pressed, the script activates. -
when this sprite clicked
— When the sprite is clicked, the script activates. -
when backdrop switches to [ v]
— When the backdrop switches to the one chosen, the script activates. -
when [ v] > ()
— When the first value is greater than the second value, the script activates. -
when I receive [ v]
— When the broadcast is received, the script activates.
Scratch 3.0 has the following two Event Stack blocks:
-
broadcast [ v]
— Sends a broadcast throughout the Scratch program, activating When I Receive () blocks that are set to that broadcast. -
broadcast [ v] and wait
— Like the Broadcast () block, but pauses the script until all scripts activated by the broadcast are completed.
Control blocks
- Main article: Control Blocks
Control blocks are the blocks that control scripts. There are 11 Control blocks in Scratch 3.0.
Scratch 3.0 has the following one Control Hat block:
-
when I start as a clone
(sprites only) — This hat block is triggered whenever a clone is created, and will only be run by that clone.
Scratch 3.0 has the following three Control Stack blocks:
-
wait () secs
— Pauses the script for the amount of time. -
wait until <>
— Pauses the script until the condition is true. -
create clone of [ v]
— Creates the specified clone.
Scratch 3.0 has the following five Control C blocks:
-
repeat ()
— A loop that repeats the specified amount of times. -
forever
— A loop that will never end. -
if <> then
— Checks the condition so that if the condition is true, the blocks inside it will activate. -
if <> then else
└— Checks the condition so that if the condition is true, the blocks inside the first C will activate and if the condition is false, the blocks inside the second C will activate. -
repeat until <>
— A loop that will stop once the condition is true.
Scratch 3.0 has the following two Control Cap blocks:
-
stop [ v]
— Stops the scripts chosen through the drop-down menu. Can also be a stack block when "other scripts in this sprite" is chosen. -
delete this clone
(sprites only) — Deletes a clone.
Sensing blocks
- Main article: Sensing Blocks
Sensing blocks are the blocks that detect things. There are 21 Sensing blocks in Scratch 3.0.
Scratch 3.0 has the following three Sensing Stack blocks:
-
ask [] and wait
— An input box appears — you type the value in and it stores the value in the(answer)
variable. -
reset timer
— Resets the timer. -
set drag mode [ v]
— Sets the sprite to draggable or not draggable.
Scratch 2.0 has the following two Sensing Boolean blocks:
-
<key [ v] pressed?>
— The condition for checking if the specified key is being pressed. -
<mouse down?>
— The condition for checking if the mouse is down.
Scratch 2.0 has the following ten Sensing Reporter blocks:
-
(distance to [ v])
— The distance from the sprite to the mouse-pointer or another sprite. -
(answer)
— The most recent input with the Ask () And Wait block. -
(mouse x)
— The mouse-pointer's X position. -
(mouse y)
— The mouse-pointer's Y position. -
(loudness)
— How loud the noise is that the microphone is sensing. -
(timer)
— How much time has passed since the Scratch program was opened or the timer reset. -
([ v] of [ v])
— The X position, Y position, direction, costume, size or volume of the Stage or a sprite. -
(current [ v])
— The specified time unit selected. -
(days since 2000)
— The number of days since 2000. -
(username)
— The username of a user.
Operators blocks
- Main article: Operators Blocks
Operators blocks are the blocks that perform math functions and string handling. There are 18 Operators blocks in Scratch 3.0.
Scratch 3.0 has the following seven Operators Boolean blocks:
-
<[] < []>
— The condition for checking if a value is less than the other. -
<[] = []>
— The condition for checking if two values are equal. -
<[] > []>
— The condition for checking if a value is greater than the other. -
<<> and <>>
— True if both conditions are true. -
<<> or <>>
— True if either condition is true. -
<not <>>
— Makes the condition checked if it is false, not true, or true, not false. -
<[] contains []?>
Checks if the first parameter's text contains the second parameter's text — if it does, the block returns true.
Scratch 3.0 has the following eleven Operators Reporter blocks:
-
(() + ())
— The value of the addition. -
(() - ())
— The value of the subtraction. -
(() * ())
— The value of the multiplication. -
(() / ())
— The value of the division. -
(pick random () to ())
— Picks a random number between the two limits. -
(join [] [])
— The two values put right next to each other. -
(letter () of [])
— The specified character of the value. -
(length of [])
— The length of the value. -
(() mod ())
— The remainder of the division. -
(round ())
— Rounds the value to the nearest whole number. -
([abs v] of ())
— The absolute value (abs), square root (sqrt), sine (sin), cosine (cos), tangent (tan), asine (asin), acosine (acos), atangent (atan), natural logarithm (ln), logarithm (log), exponential function (e^), or base 10 exponential function (10^) of a specified value.
Right-clicking some of the blocks will yield more choices of its type.
My blocks
- Main article: My Blocks
My blocks are user-made custom blocks. There are 2 unique kinds of My blocks in Scratch 3.0.
Scratch 3.0 has the following My Blocks Hat block:
-
define block
— Defines a custom block.
Scratch 3.0 has the following My Blocks Stack block:
-
custom block::custom
— A custom block.
Scratch Block Plugin
- Main article: Block Plugin
The Scratch Block Plugin allows blocks and scripts to be used in the Scratch Forums and Scratch Wiki, as well as other sites with the included JavaScript.
They look like this:
when flag clicked go to x: (0) y: (0) // center the sprite for the first stamp stamp forever go to x: (pick random (-240) to (240)) y: (0) stamp wait (0.2) secs change [color v] effect by (pick random (5) to (14))
The current version that includes all blocks from Scratch 3.0 was made by blob8108.
Editing the Block Colors
- Main article: Edit Block Colors
In the online Scratch 2.0 editor, by shift-clicking the Edit menu an option called "Edit block colors" appears. By selecting this, a menu will appear with 3 HSL sliders and tools for modifying the block colors of a specific block category. Personalized colors can be saved to one's computer, but loading the colors currently does not work properly.[citation needed]
In Other Programming Languages
Scratch is one of the original languages ever to use blocks, inspiring other languages to inherit the idea. Scratch modifications contain many new blocks typically that are not present in Scratch. MIT, where Scratch is made, has also created other languages using blocks such as the MIT App Inventor. Stencyl is a highly-professional language that features an entire block interface for programming real-time apps and online games. Scratch Jr also has blocks which are even more friendly for younger children to understand.