We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
Scratch
- This article is not detailed enough and needs to be expanded. Please help us by adding some more information.
| Paradigm(s) | Event-driven |
|---|---|
| Designed by | Resnick, Kafai, Maeda, et al. |
| Appeared in | 2003 |
| Computational class | Turing-complete |
| Reference implementation | Scratch 1.4, Scratch 2.0, Scratch 3.0 |
| Major implementations | Turbowarp (mod) PenguinMod (mod of Turbowarp) |
| Influenced | Snap!/BYOB, ScratchJr, Gandi IDE, CODE.GAME, Scrap |
| File extension(s) | .sb3, .sb2, .sb, .sprite3, .sprite2, .sprite |
Scratch is a visual programming language created in 2003 by a collaboration between MIT Media Lab's Lifelong Kindergarten Group (LLK) and UCLA, led by Mitchel Resnick and Yasmin Kafai, for teaching children how to program. It uses blocks, and has a 2D canvas (the "Stage") where sprites are on.
Sprites and the Stage
Sprites are the actors in a project. They house costumes, sounds, and scripts which allow them to interact with the Stage and each other and perform tasks. A costume is an image which a sprite displays.
The "Stage" is the space in which sprites reside. It is a 480x360-pixel canvas with the center being (0, 0), the upper-right corner being (240, 180), and the lower-left corner being (-240, -180). Just like sprites, the Stage also houses costumes (called backdrops), sounds, and scripts.
Values
Scratch has 3 types of values: IEEE 754 double-precision floating-point numbers, Booleans, and strings. However, they are not mutually exclusive and can be freely coerced into another type. For example100 may be interpreted as a string by .
Booleans when interpreted as strings return true and false respectively, while interpreting them as numbers respectively return 1 and 0.
Variables
Scratch has three types of variables: for all sprites, for this sprite only, and cloud variables. Variables that are for all sprites are like global variables, any sprite can access them. Variables that are for this sprite only can only be accessed within this sprite (with the exception of the usage of theCloud variables are special in that their value is stored in a server, which means that one user changing a cloud variable will have all other users with that project open see that change. However, they are limited to only 256 characters, may only store numbers, and are updated only 10 times per second. Cloud variables are accessible by all sprites and the Stage and usually have a ☁️ symbol prefixing their name to distinguish them from non-cloud variables. Additionally, New Scratchers (newly created Scratch accounts with not much activity yet) are unable to use the cloud functionality of cloud variables.
Creating a new project will make a variable named "my variable".
Lists
In Scratch, lists are like variables that can store multiple values. Unlike typical languages such as Python or C++, Scratch does not consider lists to be first-class values like strings and numbers are. Lists have a maximum size of 200,000 elements. Like variables, lists can be for all sprites or for this sprite only, however cloud lists do not exist and are not a planned feature in Scratch.
Scratch starts indexing at 1 instead of zero to line up with common intuition as most non-programmers and some programmers start counting at 1 instead of 0.
Blocks
By default, a new empty project in Scratch has 9 (technically 10) block categories. Each category is dedicated to a specific function, for example Motion blocks are related to the sprite's position and orientation while Operators is related to mathematical operators.
Motion
The Motion category contains blocks related to the sprite's position and orientation on the Stage. This category is not available in the Stage itself as it is stationary. There are currently 18 blocks in this category.
Every sprite has an associated X and Y position and direction. A direction of 0 degrees is facing upwards, a direction of 90 degrees is facing rightwards, a direction of 180 degrees is facing down, and a direction of -90 degrees is facing left and upside-down.
There are rotation styles which determine what a sprite looks like when it is rotated. A rotation style of "all around" is self-explanatory: the sprite is always facing in its direction. A rotation style of "left-right" makes the sprite face 90 degrees if its direction is to the right, and -90 degrees if its direction is to the left. A rotation style of "don't rotate" makes the sprite always appear to face 90 degrees. Rotation styles are purely visual, they do not affect a sprite's actual direction in any way.
| Block | Description |
|---|---|
move
10 steps |
Moves this sprite in the direction its facing by the given amount of pixels (steps). |
turn clockwise
15 degrees |
Self-explanatory. |
turn counterclockwise
15 degrees |
Self-explanatory. |
go to
random position |
Sets this sprite's position to either a random position within the Stage ( random position mouse-pointer |
go to x:
0 y:0 |
Sets the sprite's position to the given coordinates. |
glide
1 secs torandom position |
Linearly interpolates this sprite's position to the target position as of the start of invoking this block over the course of the specified duration. The target may be random position mouse-pointer |
glide
1 secs to x:0 y:0 |
Linearly interpolates this sprite's position towards the given coordinates over the course of the specified duration seconds. |
point in direction
90 |
Self-explanatory. Remember that 90 degrees is facing right, -90 degrees is upside-down and facing left, 0 degrees is up, and 180 degrees is down. |
point towards
mouse-pointer |
Points this sprite towards the target, which may either be mouse-pointer |
change x by
10 |
Changes this sprite's X position by the given amount with respect to sprite fencing. |
set x to
0 |
Sets this sprite's X position to the given value with respect to sprite fencing. |
change y by
10 |
Changes this sprite's Y position by the given amount with respect to sprite fencing. |
set y to
0 |
Sets this sprite's Y position to the given value with respect to sprite fencing. |
if on edge, bounce
|
Reflects this sprite's direction if it is touching the edges of the stage. |
set rotation style
left-right |
Sets this sprite's rotation style to the given rotation style, which is either left-right don't rotate all around |
x position
|
Returns the X position of this sprite. |
y position
|
Returns the Y position of this sprite. |
direction
|
Returns the rotation of this sprite. This is a number in the range [-180, 180]. |
Looks
The Looks category contains blocks related to the sprite's appearance. There are currently 20 blocks in this category.
Sprites have 7 visual effects: color, fisheye, whirl, pixelate, mosaic, brightness, and ghost. Color is a hue shift. Fisheye is a fisheye lens effect based on the center of the sprite's costume. Whirl is a whirl or spiral effect. Pixelate pixelates the sprite. Mosaic is a mosaic effect. Brightness determines the brightness of the sprite, with -100 being pitch-black, 0 being normal brightness, and 100 being pure white. Ghost is the transparency of the sprite, with 0 being fully opaque and 100 being fully transparent. Setting ghost to 100 while showing the sprite is different from just hiding the sprite, as hidden sprites cannot interact with other sprites.
Sprites also follow a layering system, with sprites on higher layers being drawn in front of sprites on lower layers.
| Block | Description | Stage |
|---|---|---|
say
Hello! for2 seconds |
Stalls the current script and makes this sprite say the given text inside a text bubble for the given duration in seconds. | No |
say
Hello |
Makes this sprite say the given text inside a text bubble forever or until either the script or project has been stopped. If the text is the empty string, then if the sprite is currently saying something then it stops saying that. Overrides think .
Hmm... |
No |
think
Hmm... for2 seconds |
Stalls the current script and makes this sprite say the given text inside a thought bubble for the given duration in seconds. | No |
think
Hmm... |
Makes this sprite say the given text inside a thought bubble forever or until either the script or the project has been stopped. If the text is the empty string, then if the sprite is currently saying something then it stops saying that. Overrides say .
Hello |
No |
switch costume to
costume1 |
Switches this sprite's costume to the given costume. The dropdown may be overridden with either a string or numeric expression. In the case of a string expression, the costume name is sought for, and in the case of a numeric expression the costume number is sought for. | No |
next costume
|
Switches this sprite's costume to the next costume in line. The last costume wraps around to the first costume. | No |
switch backdrop to
backdrop1 |
Switches the Stage's backdrop to the given backdrop. In the case of a string expression, the backdrop name is sought for, and in the case of a numeric expression the backdrop number is sought for. | Yes |
next backdrop
|
Switches the Stage's backdrop to the next backdrop in line. The last backdrop wraps around to the first backdrop. | Yes |
change size by
10 |
Changes this sprite's size by the given amount with respect to size fencing. | No |
set size to
100 |
Sets this sprite's size to the given size with respect to size fencing. | No |
change
color effect by25 |
Changes the given effect of this sprite by the given amount. See the list of effects above this table. | Yes |
set
color effect to0 |
Sets the given effect of this sprite to the given amount. See the list of effects above this table. | Yes |
clear graphic effects
|
Sets all of this sprite's visual effects to zero. | Yes |
show
|
Shows this sprite. This means the sprite is visible and will be able to be detected by other sprites with the Sensing blocks. | No |
hide
|
Hides this sprite. This means the sprite is invisible and will not be able to be detected by other sprites with the Sensing blocks. | No |
go to
front layer |
Sends this sprite to either the front back |
No |
go
forward 1 layers |
Sends this sprite either forwards backwards |
No |
costume
number |
Returns this sprite's current costume's number name |
No |
backdrop
number |
Returns the Stage's current backdrop's number name |
Yes |
size
|
Returns this sprite's size. For example, a sprite with 100% size will have this return 100. This is always an integer. | No |
Sounds
The Sounds category contains blocks related to playing sounds. Currently, there are 9 blocks in this category.
| Block | Description |
|---|---|
play sound
Meow until done |
Plays the given sound and hangs the current script until it finishes. Can be interrupted by stop all sounds .
|
start sound
Meow |
Plays the given sound without hanging the current script. |
stop all sounds
|
Stops all sounds that are currently playing in the project. |
change
pitch effect by10 |
Changes the given sound's pitch pan left/right |
set
pitch effect to100 |
Sets the given sound's pitch pan left/right |
clear sound effects
|
Resets the sound effects. |
change volume byto
-10 |
Changes the volume of this sprite by the given amount. |
set volume to
100 % |
Sets the volume of this sprite to the given amount. |
volume
|
Returns the volume of this sprite. It is a number in the range [0, 100]. |
Events
The Events category contains blocks related to sending and receiving events, which are a primary paradigm of Scratch. Currently, there are 8 blocks in this category.
| Block | Description |
|---|---|
when flag clicked |
Hat block that runs when the green flag is clicked. |
when space key pressed |
Hat block that runs its script when the given key is pressed. If the key is either the up or down arrow, then this will also detect mouse scrolling. |
when this sprite clicked |
Hat block that runs its script when this sprite is clicked. |
when backdrop switches to backdrop1 |
Hat block that runs its script when the Stage's backdrop switches to the given backdrop. |
when loudness >10 when timer >10 |
Hat block that runs its script when the value of either loudness or timer is greater than the given amount.
|
when I receive |
Hat block that runs its script when the given event is broadcasted. |
broadcast
message1 |
Broadcasts the given event to all sprites and the Stage. |
broadcast
message1 and wait |
Broadcasts the given event to all sprites and the Stage and hangs the current script until all scripts responding to the broadcast have finished running. |
Control
The Control category contains blocks related to control flow. Currently, there are 11 blocks in this category.
| Block | Description |
|---|---|
wait
1 seconds |
Hangs the current script for the given duration. |
repeat 10 |
Repeats the code inside it the given amount of times. The iteration count is considered only once at the start of the loop, so even if it changes while the loop is running, the loop will still loop the original amount of times. This is affected by Turbo Mode. |
forever |
Runs the code inside it forever. However, it waits for one frame before running the next iteration unless this is inside a "run without screen refresh" custom block. This is affected by Turbo Mode. |
if |
An if statement. |
if else |
An if-else statement. Unlike "traditional" programming languages however, else-if statements do not exist and thus must be done like so:
if else if else
if else |
wait until
|
Hangs the current script until the given condition is true. |
repeat until |
Repeats the code inside it until the given condition is true, in short the opposite of a while loop in "traditional" programming languages. However, it waits for one frame before running the next iteration unless this is inside a "run without screen refresh" custom block. This is affected by Turbo Mode. |
stop all stop this script stop
other scripts in sprite |
Self-explanatory. |
when I start as a clone |
Hat block that starts a script for a clone. When a clone of a sprite is created, it gains its own separate state (position, rotation, costume, effects, sprite-only variables and lists) and runs all when I start as a clone |
create clone of
target |
Creates a clone of the target sprite. If the target is myself |
delete this clone
|
Self-explanatory. |
Sensing
The Sensing category contains blocks related to sensing the state of the project and other sprites.
| Block | Description | Stage |
|---|---|---|
touching
mouse-pointer ? |
Returns whether this sprite is touching either the mouse pointer ( mouse-pointer edge |
No |
touching?
|
Returns whether this sprite is touching the given color. This is not exact as Scratch only tests the top 5 bits of the red and green channels and the top 4 bits of the blue channel.[1] | No |
coloris touching?
|
Returns whether the first color on this sprite's costume is touching the second color anywhere else. Just like touching? , this is only approximate.[1]
|
No |
distance to
mouse-pointer |
Returns the distance (in pixels) of this sprite to either the mouse-pointer |
No |
ask
What's your name? and wait |
Hangs the current script and reads a line of input from the user. Once the user has entered their answer, the built-in answer variable is set to what the user entered. Additionally, if this is running on a sprite and the sprite is shown, a text bubble containing the prompt is shown. Otherwise, the prompt is shown above the answer box instead.
|
Yes |
answer
|
A built-in for-all-sprites variable containing the user's input. This is initially set to the empty string. | Yes |
key
space pressed? |
Returns whether a key is currently being pressed. | Yes |
mouse down?
|
Returns whether the left, middle, or right mouse buttons are currently down. | Yes |
mouse x
|
Returns the X position of the mouse pointer, clamped to be within the Stage's bounds or the range [-240, 240]. | Yes |
mouse y
|
Returns the Y position of the mouse pointer, clamped to be within the Stage's bounds or the range [-180, 180]. | Yes |
set drag mode
draggable |
Sets whether this sprite is draggable not draggable |
No |
loudness
|
If the user gives Scratch permission to use their microphone, returns the loudness the user's microphone is receiving. Otherwise, it returns -1. | Yes |
timer
|
Returns the time (in seconds) since either the project has been loaded or the green flag has been clicked. | Yes |
reset timer
|
Resets the timer to zero. | Yes |
backdrop # ofStage |
Returns normally private properties of either the Stage or the given sprite. The Stage allows backdrop # backdrop name volume |
Yes |
current
year |
Returns the current thing. thing is one of year month date day of week hour minute second |
Yes |
days since 2000
|
Self-explanatory. Also returns fractional portions of a day. | Yes |
online?
|
Returns whether the user is using Scratch online or offline. | Yes |
username
|
Returns the user's Scratch username. If they are not logged in, this returns the empty string. | Yes |
Operators
The Operators category contains blocks that perform operations on values. Currently, there are 18 blocks in this category.
| Block | Description |
|---|---|
+
|
Numeric addition. |
-
|
Numeric subtraction. |
*
|
Numeric multiplication. |
/
|
Numeric division. Division by zero returns infinity, and zero divided by zero returns NaN. |
pick random
1 to10 |
Chooses a random number between the two numbers. If either operand is a direct numeric literal and the numeric literal has a decimal point, then the decimals will be randomized too. They do not have to be in ascending order. |
>
50 |
Self-explanatory. |
<
50 |
Self-explanatory. |
=
50 |
Self-explanatory. |
| Boolean AND. | |
| Boolean OR. | |
not
|
Boolean NOT. |
join
apple banana |
Treats both operands as a string and concatenates them. |
letter
1 ofapple |
Returns the Nth character of the string, starting from 1. The first operand is the index and the second operand is the string to get the Nth character of. |
length of
apple |
Returns the length of the operand as a string in characters. |
apple containsa ? |
Returns whether the first string contains the second string. |
mod
|
Numeric modulo. Modulo by zero returns NaN. |
round
|
Rounds the number according to IEEE 754 double-precision rounding rules. |
abs of |
Applies a function onto a value, which is either abs floor ceiling sqrt sin cos tan asin acos atan ln e ^ 10 ^ |
Variables
The Variables category contains blocks that work with variables and lists.
The Lists category could be considered separate from the Variables category since Scratch considers variables and lists to be completely separate things unlike other languages such as Ruby and C++ where lists are first-class values that can be stored into variables and other lists.
| Block | Description |
|---|---|
set
my variable to0 |
Sets the given variable to the given value. |
change
my variable by1 |
Adds the given value to the given variable's value. |
my variable
|
Returns the value of the variable. |
show
my variable |
Shows the variable reporter of the variable on the stage. |
hide
my variable |
Hides the variable reporter of the variable on the stage. |
add
thing tomy list |
Appends the value to the end of the list. |
delete
1 ofmy list |
Deletes the item of the list at the specified index. |
delete all of
my list |
Self-explanatory. |
insert
thing at1 ofmy list |
Self-explanatory. |
replace item
1 ofmy list withthing |
Self-explanatory. |
item
1 ofmy list |
Retrieves the Nth item of the list. Returns the empty string if the index is out of bounds. |
item # of
1 inmy list |
If the item is in the list, then returns the index of the first occurrence of it in the list, otherwise zero. |
length of
my list |
Self-explanatory. |
my list containsthing ? |
Self-explanatory. |
show list
my list |
Shows the list display of the list on the stage. |
hide list
my list |
Hides the list display of the list on the stage. |
my list
|
Returns the a string of the concatenated values of all of the elements in the list. If the elements of the list are all zero- or one-character strings, then they are concatenated normally. Otherwise, they are separated with spaces. |
My Blocks
My Blocks is a category containing custom blocks defined by the user. They can be thought of as procedures in more "traditional" languages like COBOL. In a new project, there are no custom blocks and so there is nothing in this category until the user makes a new custom block in a sprite. Custom blocks are also sprite-specific, so if you wish to have the same custom block in multiple sprites, the only way to do that is to copy the custom blocks to the sprites you want to use them in.
Upon creating a new block, a definition for it will be inserted in the current sprite and the block to invoke it will appear in the My Blocks section. The definition is a big hat block with the text "define" next to a replica of the block, but with the named parameters taking the places of the inputs. When creating a custom block, labels and parameters (numeric/string or Boolean) may also be added. Additionally, custom blocks can be specified to "Run without screen refresh". Custom blocks marked with "Run without screen refresh" will make blocks that normally wait for the next frame not wait for the next frame. However, having a block run for more than a frame or forever such asExtensions
Scratch also supports 12 built-in extensions that are disabled by default but can be enabled via the "Extensions" tab below the block category list.
Music
The Music extension enables projects to play musical instruments and make music much easier. Currently, this extension has 7 blocks.
| Block | Description |
|---|---|
🎶 play drum
(1) Snare Drum for0.25 beats |
Plays the given drum sound for the given amount of beats. Hangs the current script until the drum has finished. drum is of the format "(Drum Number) Drum Name)", so for example Snare Drum would be "(1) Snare Drum". See the list of drums below.
|
🎶 rest for
0.25 beats |
Hangs the current script for the given amount of beats. |
🎶 play note
60 for0.25 beats |
Plays the given MIDI note for the given amount of beats with the current instrument. Hangs the current script until the note is finished. |
🎶 set instrument to
(1) Piano |
Sets this sprite's current instrument to the given instrument, which is of the format "(Instrument Number) Instrument Name", so Piano would be "(1) Piano". See the list of instruments below. |
🎶 set tempo to
60 |
Sets the tempo to the given value. |
🎶 change tempo by
20 |
Changes the tempo by the given value. |
🎶 tempo
|
A built-in variable shared by all sprites and the Stage that stores the tempo in beats per minute. By default, this is 60. |
Drums
This is a complete list of drums that the- Snare Drum
- Bass Drum
- Side Stick
- Crash Cymbal
- Open Hi-Hat
- Closed Hi-Hat
- Tambourine
- Hand Clap
- Claves
- Wood Block
- Cowbell
- Triangle
- Bongo
- Conga
- Cabasa
- Guiro
- Vibraslap
- Cuica
Instruments
This is a complete list of the instruments that the Music extension uses. Currently, there are 21 instruments.
- Piano
- Electric Piano
- Organ
- Guitar
- Electric Guitar
- Bass
- Pizzicato
- Cello
- Trombone
- Clarinet
- Saxophone
- Flute
- Wooden Flute
- Bassoon
- Choir
- Vibraphone
- Music Box
- Steel Drum
- Marimba
- Synth Lead
- Synth Pad
Pen
The Pen extension is used to draw arbitrary shapes and images to the Stage. Anything drawn by the Pen extension draws behind all sprites, but in front of the Stage. Since the Stage itself is stationary, only the| Block | Description |
|---|---|
🖋️ erase all
|
Erases everything drawn by the Pen extension. |
🖋️ stamp
|
"Stamps" this sprite onto the Pen canvas, or in other words draws a copy of the sprite's current costume along with any graphical effects onto the Pen canvas. |
🖋️ pen down
|
Brings the "pen" of this sprite down. This means that the pen starts drawing, and any change in position will result in a line being drawn from the previous position to the next. |
🖋️ pen up
|
Brings the "pen" of this sprite up. |
🖋️ set pen color to
|
Sets the pen color to the given color. |
🖋️ change pen
color by50 |
Changes the given attribute of the pen by the given amount. The attribute may be color saturation brightness transparency |
🖋️ set pen
color to50 |
Sets the given attribute of the pen to the given amount. The attribute may be color saturation brightness transparency |
🖋️ change pen size by
1 |
Changes the diameter of the pen by the given amount with respect to pen size fencing. |
🖋️ set pen size to
1 |
Sets the diameter of the pen to the given amount of pixels with respect to pen size fencing. |
Video Sensing
The Video Sensing extension allows the project to sense the camera feed. Currently, this extension has 4 blocks.
| Block | Description |
|---|---|
🎥 when video motion > 10 |
Hat block that runs whenever the video motion is greater than the specified amount. |
🎥 video
motion onsprite |
Returns the either the video motion or direction on either this sprite or the Stage. If the user denies permission to their camera, returns -1. |
🎥 turn video
on |
Turns the video feed either on or off on flipped |
🎥 set video transparency to
50 |
Sets the transparency of the video feed shown on the Stage to the given amount, which is a number in the range [0, 100]. |
Face Sensing
The Face Sensing extension allows the project to sense the user's face through the camera.
| Block | Description |
|---|---|
🙂 go to
nose |
Sets the sprite's position to the position on the stage of the detected part of the face. See the list below this table. |
🙂 point in direction of face tilt
|
Self-explanatory. |
🙂 set size to face size
|
Self-explanatory. |
🙂 when face tilts left |
Self-explanatory hat block that runs its script whenever the face tilts either left or right. |
🙂 when this sprite touches a nose |
Self-explanatory. See the list below this table. |
🙂 when a face is detected |
Self-explanatory hat block that runs its script whenever a face is detected. |
🙂 a face is detected?
|
Self-explanatory. If the user does not allow Scratch to use their camera, this always returns false. |
🙂 face tilt
|
Returns the face tilt in degrees. If the user does not allow Scratch to use their camera, this returns 90. |
🙂 face size
|
Returns the size of the detected face. If the user does not allow Scratch to use their camera, this returns 100. |
This is a list of the parts of a face that Face Sensing supports.
- nose
- mouth
- left eye
- right eye
- between eyes
- left ear
- right ear
- top of head
Text to Speech
The Text to Speech extension provides TTS (text-to-speech) services for Scratch via the network. This extension currently has 3 blocks.
| Block | Description |
|---|---|
📢 speak
hello |
Speaks the text using this sprite's current TTS voice and language. |
📢 set voice to
alto |
Sets this sprite's TTS voice to the given voice. The voices are alto tenor squeak giant kitten |
📢 set language to
English |
Sets this sprite's TTS language to language. The languages available are Arabic, Chinese (Mandarin), Danish, Dutch, English, French, German, Hindi, Icelandic, Italian, Japanese, Korean, Norwegian, Polish, Portuguese (Brazilian), Portuguese, Romanian, Russian, Spanish, Spanish (Latin American), Swedish, Turkish, and Welsh.
|
Translate
The Translate extension allows translating text on the fly using the network. Currently, this extension has 2 blocks.
| Block | Description |
|---|---|
💬 translate
hello toNorwegian |
Translate the given text from an auto-detected language to the given target language. See the list of languages below. |
💬 language
|
Returns the user's set language. |
This is a complete list of the languages that the Translate extension supports.
- Amharic
- Arabic
- Azerbaijani
- Basque
- Bulgarian
- Catalan
- Chinese (Simplified)
- Chinese (Traditional)
- Croatian
- Czech
- Danish
- Dutch
- English
- Estonian
- Finnish
- French
- Galician
- German
- Greek
- Hebrew
- Hungarian
- Icelandic
- Indonesian
- Irish Gaelic
- Italian
- Japanese
- Korean
- Kurdish (Sorani)
- Latvian
- Lithuanian
- Maori
- Norwegian
- Persian
- Polish
- Portuguese
- Romanian
- Russian
- Scots Gaelic
- Serbian
- Slovak
- Slovenian
- Spanish
- Swedish
- Thai
- Turkish
- Ukranian
- Vietnamese
- Welsh
- Zulu
Makey Makey
This extension has two blocks.
| Block | Description |
|---|---|
🎮 when space key pressed |
Self-explanatory hat block that runs its script whenever the given key is pressed. Unlike the when space key pressed |
🎮 when left up right pressed in order |
Self-explanatory hat block that runs its script when the given sequence of keys is pressed in order. The list of key sequences can be found below this table. |
- left right up
- right up left
- left right
- up down
- down up
- up right down left
- up left down right
- up up down down left right left right
micro:bit
The micro:bit extension provides blocks for Scratch to be able to interact with the micro:bit. Currently, there are 10 blocks in this extension.
| Block | Description |
|---|---|
⌨️ when A button pressed |
Hat block that runs its script when the given button of the micro:bit is pressed. The button is either A B any |
⌨️
A button pressed? |
A block that returns whether the given button of the micro:bit is pressed. The button is either A B any |
⌨️ when moved |
Hat block that runs its script when the given action is performed with the micro:bit. The action is either moved shaken jumped |
⌨️ display
▄▀▄▀▄ ▀▄ ▄▀ ▀ |
Displays the given 5x5 pattern on the micro:bit's display. |
⌨️ display text
Hello |
Displays the given text on the micro:bit's text display. |
⌨️ clear display
|
Clears the micro:bit's display. |
⌨️ when tilted any |
Hat block that runs its script when the micro:bit is tilted in the direction in the given direction. See the list of tilt directions below this table. |
⌨️ tilted
any ? |
Returns whether the micro:bit is being tilted in the given direction. See the list of tilt directions below this table. |
⌨️ tilt angle
front |
Returns the tilt angle of the micro:bit in the given direction, which can be any of the tilt directions listed below this table except for any |
⌨️ when pin 0 connected |
Hat block that runs its script when the given pin (0, 1, or 2) is connected. |
The list of tilt directions.
- any
- front
- back
- left
- right
Go Direct Force & Acceleration
The Go Direct Force & Acceleration extension provides blocks that interact with the Vernier Go Direct Force and Acceleration sensor.[2] Currently, there are 9 blocks in this category.
| Block | Description |
|---|---|
📱 when shaken |
Hat block that runs its script when the given action is performed on the force sensor. The action is either shaken started falling turned face up turned face down |
📱 when force sensor pushed |
Hat block that runs its script when action is performed on the force sensor. The action is either pushed pulled |
📱 force
|
Returns the force the force sensor is experiencing.[unsure] |
📱 when tilted any |
Hat block that runs its script when the force sensor is tilted in the given direction. The list of directions is the same as that of the micro:bit. |
📱 tilted
front ? |
Returns whether the force sensor is tilted in the given direction. The list of directions is the same as that of the micro:bit. |
📱 tilt angle
front |
Returns the force sensor's tilt angle in the given direction, where direction can be any direction from the list of directions except any. The list of directions is the same as that of the micro:bit.
|
📱 falling?
|
Returns whether the force sensor is falling. |
📱 spin speed
x |
Returns the force sensor's spin speed on the given axis, which is either "x", "y", or "z". |
📱 acceleration
x |
Returns the force sensor's acceleration on the given axis, which is either "x", "y", or "z". |
LEGO MINDSTORMS EV3
- This section is a stub. Please help us by adding more information.
The LEGO MINDSTORMS EV3 extension provides blocks that allow programming the EV3 with Scratch.[3]
| Block | Description |
|---|---|
🖥️ motor
A turn this way for1 seconds |
Turns[what direction?] the given motor (A, B, C, or D) for the given duration and hangs the script until it is done. |
🖥️ motor
A turn that way for1 seconds |
Turns[what direction?] the given motor (A, B, C, or D) for the given duration and hangs the script until it is done. |
🖥️ motor
A set power100 % |
Sets the power of the given motor (A, B, C, or D) to the given amount. |
🖥️ motor
A position |
Returns the position[exact meaning?] of the given motor, which is one of A, B, C, or D. |
🖥️ when button 1 pressed |
Hat block that runs its script whenever the given button (one of 1, 2, 3, or 4) is pressed. |
🖥️ when distance < 5 |
Hat block that runs its script when the distance[what distance?] is less than the given amount. |
🖥️ button
1 pressed? |
Returns whether the given button (one of 1, 2, 3, or 4) is pressed. |
🖥️ distance
|
Returns the distance.[what distance?] |
🖥️ brightness
|
Returns the brightness.[what brightness?] |
🖥️ beep note
60 for0.5 secs |
Beeps the MIDI note note for duration seconds and hangs the script until it is done.
|
LEGO BOOST
- This section is a stub. Please help us by adding more information.
LEGO Education WeDo 2.0
- This section is a stub. Please help us by adding more information.
Examples
These are all written in Scratch 3.0.
Hello, world! program
Cat program
Ha, get it? Because Scratch's mascot is the Scratch Cat? And "cat program" got its name from UNIX cat?
One Time Cat
Ha, get it!? Because Scratch's mascot is the Scratch Cat, which is a cat (duh), and "cat program", "One Time Cat", from UNIX cat for "conCATenate" but that's also the word for kitties!!! AHAHAHAHHAHAHA!!!!
Looping counter
Truth-machine
If the input is zero, meows once. Otherwise, meows forever.
99 bottles of beer
The output is stored in a list named "output".
Bitwise Cyclic Tag
See Also
- Scratch is dumb but useful
- Scratch is dumb
- Esolang Simply Created To Annoy People Who Dislike Scratch
- Hopscotch (Hopscotch Technologies)
References
- ↑ 1.0 1.1 https://github.com/scratchfoundation/scratch-editor/blob/82c5fea6d3e60c781f25c09b375045f9b46a43f7/packages/scratch-render/src/RenderWebGL.js#L77 Scratch only tests if two colors are "close enough" by checking the upper 5 bits for RG and upper 4 bits for B.
- ↑ https://scratch.mit.edu/vernier
- ↑ https://scratch.mit.edu/ev3