Blocks(2.0)
when gf clicked move (10) steps say [Hello!] for (2) seconds forever if <<(score::variables) \> (50)> and <touching (mouse-pointer v)?>> then dance for (2) seconds::custom broadcast (Win v) play sound (Cheer v) until done repeat (100) beep note (pitch::variables) for (0.1) secs change [pitch v] by (1)
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 block type (hat, stack, reporter, boolean, or cap) has its own shape and its own slot shape for it to be inserted into. Series of connected blocks are called scripts.
Blocks are often easier to work with than text-based programming, as blocks do not need to be memorized like typed commands and syntax errors cannot occur. However, text-based programming is more flexible, as text can easily be edited without having to drag another block into the editor.
There are ten categories of blocks: Motion, Looks, Sound, Event, Control, Sensing, Operators, Variables, List, and My Blocks. The list blocks are shown under the Variables Blocks.
In total, there are eight Hat Blocks, five C Blocks, 34 Reporter Blocks, 14 Boolean Blocks, two Cap Blocks and 62 Stack Blocks, for a total of 125 blocks. (Block numbers do not include extensions.)
Block Shapes
There are six different block shapes: Hat, Stack, Boolean, Reporter, C and Cap.
Hat blocks
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 that a user can only place blocks below them. There are eight 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
Stack blocks are the blocks that perform specific 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 62 Stack blocks — the most common block shape.
Boolean blocks
Boolean blocks are blocks that act like conditions. They have an elongated hexagonal shape. Boolean blocks can hold and report "true" or "false" values. These blocks are inserted into holes of other blocks with the same shape.
Reporter blocks
Reporter blocks are blocks that act as the values. They are shaped with rounded edges. Reporter blocks can hold numbers and strings. They can also report a variable. Theoretically, there are an infinite amount of Reporter blocks that can be made for each variable and list. These blocks are inserted into holes of other blocks with the same shape.
C blocks
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, allowing blocks to be attached below, or capped, which does not allow any blocks to be placed below.
Cap blocks
Cap blocks are the blocks that end scripts. They are shaped with a notch at the top and a flat bottom — this is so blocks cannot be placed below them. There are two Cap blocks, which can both be found in the Control category.
Block Categories
Blocks are divided into 9 categories: Motion, Looks, Sound, Events, Control, Sensing, Operators, Variables, and My Blocks. Each category has blocks that perform a different function. There are also 11 extension categories that can be added to the block list by selecting them, and 3 Raspberry Pi extensions that are not available on other versions of Scratch. The block categories appear in the categories to the left of the Block Palette, and extensions will appear there when they are added.
List of Blocks
There are 125 normal blocks in Scratch 3.0 (not including extensions or hidden blocks). There are 80 extension blocks (not including Raspberry Pi blocks). There are also many Hidden Blocks that cannot be accessed normally.
The following is a list of said 125 blocks, divided and listed based on category:
Motion blocks
Motion blocks are the blocks that control a Sprite's movement. There are 17 Motion blocks in Scratch 3.0. The stage has no motion blocks, as it cannot move.
Motion has 15 stack blocks and 3 reporter 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.go to ( v)
— Moves the sprite to the mouse-pointer, a random position, or another sprite.go to x: () y: ()
— Moves the sprite to the specified X and Y position.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 timeglide () secs to x: () y: ()
— Glides the sprite to the location, taking as long as the specified amount of time.point in direction ()
— Points the sprite in the direction.point towards ( v)
— Points the sprite towards the mouse-pointer or another sprite.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 overset rotation style [ v]
— Sets the rotation style of a sprite.(x position)
— The X position of the sprite.(y position)
— The Y position of the sprite.(direction)
— The direction of the sprite.
Looks blocks
Looks blocks are the blocks that control how a sprite looks. There are 23 Looks blocks in Scratch 3.0. Three of the 19 sprite Looks blocks have a counterpart for the Stage.
Looks has 18 stack blocks and 3 reporter blocks:
say [] for () seconds
— 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 only go away if the sprite says or thinks something else.think [] for () seconds
— 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 only go away if the sprite says or thinks something else.switch costume to ( v)
— Changes the sprite's costume to the specified one.next costume
— Changes the sprite's costume to the next one in the costume list.switch backdrop to ( v)
— Changes the stage's 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 backdrop
— Changes the stage's backdrop to the next one in the costume listchange size by ()
— Changes the sprite's size by the amount.set size to ()%
— Sets the sprite's size to the amount.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.show
— Shows the sprite.hide
— Hides the sprite.go to [ v] layer
— Puts a sprite in the front or back.go [ v] () layers
— Changes the sprite's layer value by the amount.(costume [ v])
— The number or name of the sprite current costume in the list.(backdrop [ v])
— The number or name of the Stage's current backdrop in the list.(size)
— The sprite's size.
Sound blocks
Sound blocks are the blocks that control sound. There are 9 Sound blocks in Scratch 3.0. The note blocks in 3.0 have been moved to the Music Extension.
Sound has 8 stack blocks and 1 reporter block:
play sound ( v) until done
— Plays a sound and pauses the script until it finishes.start sound ( v)
— Plays a sound without pausing the script.stop all sounds
— Stops all playing sounds.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.change volume by ()
— Changes the volume by the amount.set volume to ()%
— Sets the volume to the amount.(volume)
— The volume.
Events blocks
Events blocks are blocks that control events and the triggering of scripts. There are 8 Event blocks in Scratch 3.0.
Events has 6 hat blocks and 2 stack 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. The event will only be triggered again after the event is released.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.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
Control blocks are the blocks that control scripts. There are 11 Control blocks in Scratch 3.0.
Control has 1 hat block, 3 stack blocks, and 5 C blocks:
wait () seconds
— Pauses the script for the amount of time.repeat ()
— A loop that repeats the specified amount of times.forever
— A loop that will never end unless the Stop Sign is pressed or the script is stopped by the Шаблон:B block.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.wait until <>
— Pauses the script until the condition is true.repeat until <>
— A loop that will stop once the condition is true.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.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.create clone of ( v)
— Creates the specified clone.delete this clone
(sprites only) — Deletes a clone.
Sensing blocks
Sensing blocks are the blocks that detect things. There are 18 Sensing blocks in Scratch 3.0.
Sensing has 3 stack blocks, 5 boolean blocks, and 10 reporter blocks:
<touching ( v)?>
— The condition for checking if the sprite is touching the mouse-pointer or another sprite.<touching color [#0000ff]?>
— The condition for checking if the sprite is touching a specific color.<color [#0000ff] is touching [#ff0000]?>
— The condition for checking if a color on the sprite is touching a specific color.(distance to ( v))
— The distance from the sprite to the mouse-pointer or another sprite.ask [] and wait
— An input box appears — a value is typed in and it stores the value in the(answer)
variable.(answer)
— The most recent input with the Ask () And Wait block.<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.(mouse x)
— The mouse-pointer's X position.(mouse y)
— The mouse-pointer's Y position.set drag mode [ v]
— Sets the sprite to draggable or not draggable.(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.reset timer
— Resets the timer.([ 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
Operators blocks are the blocks that perform math functions and string handling. There are 18 Operators blocks in Scratch 3.0.
Operators has 7 boolean blocks and 11 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.<[] > []>
— The condition for checking if a value is greater than the other.<[] < []>
— The condition for checking if a value is less than the other.<[] = []>
— The condition for checking if two values are equal.<<> 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.(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.<[] contains []?>
Checks if the first parameter's text contains the second parameter's text — if it does, the block returns true.(() 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.
Variables blocks
Variables blocks are the blocks that hold variables and lists. There are 5 Variables blocks and 11 list blocks in Scratch 3.0.
Variables has 4 stack blocks and one reporter block for each variable created:
(variable)
— The variable's value.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.
List blocks
List blocks are the blocks that manage lists. They are located in the Variables category and are not found in the bar to the left. There are 12 List blocks in Scratch 3.0.
List has 7 stack blocks, 3 reporter blocks (one additional reporter block for each list created), and 1 boolean block:
(list::list)
— All items contained in the list.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 it is specified 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.(item () of [ v])
— The item's value.(item # of [] in [ v])
— Reports the index in a list where an item first appears.(length of [ v])
— How many items there are in the specified list.<[ v] contains []?>
— The condition for checking if an item's content is the specified text.show list [ v]
— Shows a list.hide list [ v]
— Hides a list.
My Blocks
My Blocks (also known as Custom Blocks), are user-made custom blocks. There are 4 different, unique kinds of My Blocks in Scratch 3.0. Scratch 3.0 has the following My Blocks Hat block:
define custom block
— Defines a custom block.
Scratch 3.0 has the following My Blocks Stack block:
custom block:: custom
— A custom block.
Scratch 3.0 has the following My Blocks Boolean block:
<custom boolean::custom>
— A true/false value.
Scratch 3.0 has the following My Blocks Reporter block:
(custom reporter::custom)
— An input for a value, set by the definition My Block.
Extensions
Scratch 3.0 has a number of extensions that can be added to the block list. To choose an extension, press the blue button below the regular block sections.
Music Extension
The Music extension allows one to play MIDI Notes with different instruments. There are seven Music extension blocks in Scratch 3.0.
Scratch 3.0 has six Music stack blocks and one Music reporter block:
play drum ( v) for (0.25) beats
rest for () beats
play note () for () beats
set instrument to ( v)
set tempo to ()
change tempo by ()
tempo::reporter
Pen Extension
Шаблон:Main The Pen extension allows one to draw on the stage with the pen. Scratch 3.0 has nine Pen stack blocks:
erase all
stamp
pen up
pen down
set pen color to [#cd4f39]
change pen ( v) by ()
set pen ( v) to ()
change pen size by ()
set pen size to ()
Video Sensing Extension
Шаблон:Main The Video Sensing extension lets projects interact with a webcam. There are four Video Sensing blocks in Scratch 3.0.
Scratch 3.0 has one Video Sensing hat block, one reporter block, and two stack blocks:
Text to Speech Extension
Шаблон:Main The Text to Speech extension allows text to be read aloud. Scratch 3.0 has three Text to Speech stack blocks:
Translate Extension
The Translate extension allows text to be translated to other languages. Scratch 3.0 has two Translate reporter blocks:
Makey Makey Extension
The Makey Makey extension lets projects interact with the Makey Makey. Scratch 3.0 has two Makey Makey hat blocks:
micro:bit Extension
The micro:bit extension lets projects interact with the micro:bit. There are 10 micro:bit blocks in Scratch 3.0.
Scratch 3.0 has four micro:bit hat blocks, three stack blocks, two boolean blocks, and one reporter block:
when ( v) button pressed
<( v) button pressed?>
when ( v)::microbit
display ( v)::microbit
display text ()::microbit
clear display::microbit
when tilted ( v)::microbit hat
<tilted ( v)?::microbit>
tilt angle ( v)::microbit
when pin ( v) connected
LEGO MINDSTORMS EV3 Extension
The LEGO MINDSTORMS EV3 extension lets projects interact with the LEGO MINDSTORMS EV3. There are 11 EV3 blocks in Scratch 3.0.
Scratch 3.0 has four EV3 stack blocks, three hat blocks, three reporter blocks, and one boolean block.
motor ( v) turn this way for () seconds
motor ( v) turn that way for () seconds
motor ( v) set power ()%
(motor ( v) position::ev3)
when button ( v) pressed
when distance \<()
when brightness \<()
<button ( v) pressed?::ev3>
distance::ev3
brightness::ev3
beep note () for () secs
LEGO BOOST Extension
The LEGO BOOST extension lets projects interact with the LEGO BOOST. There are 12 LEGO BOOST blocks in Scratch 3.0.
Scratch 3.0 has seven Lego BOOST stack blocks, two reporter blocks, two hat blocks, and one boolean block:
turn motor ( v) for () seconds
turn motor ( v) for () rotations
turn motor ( v) on
turn motor ( v) off
set motor ( v) speed to ()%
set motor ( v) direction ( v)
motor ( v) position::boost
when ( v) brick seen
seeing ( v) brick?
when tilted ( v)::boost
tilt angle ( v)::boost
set light color to ()::boost
LEGO Education WeDo 2.0 Extension
The Lego Education WeDo 2.0 extension lets projects interact with the LEGO WeDo Construction Set. There are 11 blocks in Scratch 3.0.
Scratch 3.0 contains six Lego Education WeDo 2.0 stack blocks, two hat blocks, two reporter blocks, and one boolean block:
turn ( v) on for () seconds
turn ( v) on
turn ( v) off
set ( v) power to ()
set ( v) direction to ( v)
set light color to ()
when distance ( v) ()
when tilted ( v)::wedo
distance::wedo
tilted ( v)?::wedo
tilt angle ( v)::wedo
Go Direct Force & Acceleration Extension
The Go Direct Force & Acceleration Extension allows users to interact with the Go Direct force sensor.
Scratch 3.0 contains 4 Go Direct Force & Acceleration reporter blocks, three hat blocks, and two boolean blocks.
when (shaken v)
when force sensor ( v)
(force)
when tilted ( v)::gdxfor
<tilted ( v)?::gdxfor>
tilt angle ( v)::gdxfor
<falling?>
(spin speed ( v))
(acceleration ( v))
Raspberry Pi Only Extensions
There are also three extensions that are only available on the Raspberry Pi version of Scratch.
Raspberry Pi GPIO Extension
Scratch 3.0 contains 2 Raspberry Pi GPIO stack blocks, one hat block, and one boolean block.
when gpio (0 v) is [high v]:: extension hat
<gpio (0 v) is [high v]?:: extension>
set gpio (0 v) to output [high v]:: extension
set gpio (0 v) to input [pulled high v]:: extension
Raspberry Pi Sense HAT Extension
Scratch 3.0 contains ten Raspberry Pi Sense HAT stack blocks, three hat blocks, one boolean block, and six reporter blocks.
display text [Hello!]:: extension
display character [A]:: extension
- Шаблон:NbspФайл:Display () Sense HAT.png
display sprite:: extension
display stage:: extension
clear display:: extension
set colour to [#2d184f]:: extension
set background to [#4160b5]:: extension
set pixel x (0 v) y (0 v) to [#5eb87c]:: extension
set rotation to [0 v] degrees:: extension
when joystick pushed [up v]:: extension hat
<joystick pushed [up v]?:: extension>
when shaken:: extension hat
when tilted [forward v]:: extension hat
(temperature:: extension)
(pressure:: extension)
(humidity:: extension
(roll:: extension)
(pitch:: extension)
(yaw:: extension)
Raspberry Pi Simple Electronics Extension
Scratch 3.0 contains two Raspberry Pi Simple Electronics stack blocks, one boolean block, and one hat block.
when button (0 v) is [pressed v]:: extension hat
<button (0 v) is [pressed v]?:: extension>
turn LED (0 v) [on v]:: extension
toggle LED (0 v):: extension
Scratch Block Plugin
The Block Plugin allows one to write blocks and scripts to appear on the Scratch Forums and Scratch Wiki, as well as other websites with the included JavaScript. It is written by the Scratcher blob8108. The dedicated forum topic for testing this plugin out can be found.
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.