From Test-Scratch-Wiki
(Redirected from Eng:Block)
- This article or section documents an outdated version of Scratch (version 2.0). For this article in Scratch 1.4, see Eng:Blocks (1.4).
- This eng is about the programming blocks. For account blocks, see Ban.
Blocks are puzzle-piece shapes that are used to create code in Scratch. The blocks connect to each other like a jigsaw puzzle, where each data type (event, command, reported value, reported boolean, or script end) has its own shape and a specially shaped slot for it to be inserted into
— this prevents syntax errors. Series of connected blocks are called scripts.
There are twelve categories of blocks: Motion, Looks, Sound, Pen, Variables, List, Event, Control, Sensing, Operators, PicoBoard, and LEGO WeDo (although there are some other categories and blocks in some Scratch modifications). Only ten are shown in the Block Palette.
In total, there are eleven hat blocks, five C blocks, thirty-seven reporter blocks, thirteen Boolean blocks, two cap blocks and seventy-seven stack blocks.
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, six of which are in the Events category, one in the Control category, and four More hat blocks. Some examples of hat blocks are: when gf clicked
, or when this sprite clicked
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. It is like asking your friend: "Does 2 + 2 = 4?", and they 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 is not just equations however, it can report a variable, for example, "What is your age?". 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 145 blocks in Scratch 2.0.
Motion blocks
- Main article: Motion Blocks
Motion blocks are the blocks that control a sprite's movement. There are 17 Motion blocks in Scratch 2.0.
Scratch 2.0 has the following fourteen Motion Stack blocks:
— Moves the sprite forward the amount of steps in the direction the sprite is facing.
— Turns the sprite (clockwise) the specified amount.
— Turns the sprite (counter-clockwise) the specified amount.
— Points the sprite in the direction.
— Points the sprite towards the mouse-pointer or another sprite.
— Moves the sprite to the specified X and Y position.
— Moves the sprite to the mouse-pointer or another sprite.
— Glides the sprite to the location, taking as long as the specified amount of time.
— Changes the sprite's X position by the amount.
— Sets the sprite's X position to the amount.
— Changes the sprite's Y position by the amount.
— Sets the sprite's Y position to the amount.
— If touching the edge of the screen, the sprite's direction flips over.
Set Rotation Style () — This sets the rotation style of a sprite.
Scratch 2.0 has the following three Motion Reporter blocks:
— The X position of the sprite.
— The Y position of the sprite.
— 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 2.0. Three of the 19 sprite Looks blocks have a counterpart for the Stage.
Scratch 2.0 has the following sixteen Looks Stack blocks:
— A speech bubble appears over the sprite and stays for the specified amount of time.
— A speech bubble appears over the sprite and will not go away over time.
— A thought bubble appears over the sprite and stays for the specified amount of time.
— A thought bubble appears over the sprite and will not go away over time.
— Shows the sprite.
— Hides the sprite.
— Changes the sprite's/Stage's costume/backdrop to the specified one.
— Like the Switch to Backdrop () block, though it waits until all of the hat blocks triggered by this have completed. (Stage only)
— Changes the sprite's/Stage's costume/backdrop to the next one in the costume list.
— Changes the specified effect by the amount.
— Sets the specified effect to the amount.
— Clears all graphic effects on the sprite.
— Changes the sprite's size by the amount.
— Sets the sprite's size to the amount.
— Puts a sprite in the front.
— Changes the sprite's layer value by the amount.
Scratch 2.0 has the following three Looks Reporter blocks:
— The number of the sprite/Stage's current costume/backdrop in the list.
— Reports the name of the current backdrop.
— The sprite's size.
Sound blocks
- Main article: Sound Blocks
Sound blocks are the blocks that control sound and MIDI functions. There are 13 Sound blocks in Scratch 2.0.
Scratch 2.0 has the following eleven Sound Stack blocks:
— Plays a sound without pausing the script.
— Plays a sound and pauses the script until it finishes.
— Stops all playing sounds.
— Plays the specified drum for the amount of beats.
— Pauses the script for the amount of time.
— Plays the note for the amount of beats.
— Sets the instrument to the specified one.
— Changes the volume by the amount.
— Sets the volume to the amount.
— Changes the tempo by the amount.
— Sets the tempo to the amount.
Scratch 2.0 has the following two Sound Reporter blocks:
— The volume.
— The tempo.
Pen blocks
- Main article: Pen Blocks
Pen blocks are the blocks that control the pen. There are 11 Pen blocks in Scratch 2.0.
Scratch 2.0 has the following eleven Pen Stack blocks:
— Removes all pen marks put on the screen.
— Pens the sprite's image on the screen. Can be removed using clear.
— Puts the sprite's pen down.
— Puts the sprite's pen up.
— Sets the pen color to the specified color shown on the picture.
— Changes the pen color by the amount.
— Sets the pen color to the amount.
— Changes the pen shade by the amount.
— Sets the pen shade to the amount.
— Changes the pen size by the amount.
— Sets the pen size to the amount.
The Scratch Day pre-alpha of Scratch 2.0 had the following one new Pen Stack block:
— Pens the sprite's image on the screen at the transparency of the amount in the block. Can be removed using clear. This was made obsolete, because now ghost effect is respected when stamping.
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 2.0.
Scratch 2.0 has the following four Variables Stack blocks:
— Sets the specified variable to the amount.
— Changes the specified variable by the amount.
— Shows the variable's Stage Monitor.
— Hides the variable's Stage Monitor.
Scratch 2.0 has the following Variables Reporter block:
— 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 10 List blocks in Scratch 2.0.
Scratch 2.0 has the following six List Stack blocks:
— Adds an item to the list (the item goes at the bottom of the list of items) with the specified content in it.
— Deletes the item of the list.
— Adds an item to the list (the item goes where you specify in the list of items) with the specified content in it.
— Replaces the item's content with the specified content.
— Shows a list.
— Hides a list.
Scratch 2.0 has the following 3 List Reporter blocks:
— The list's value.
— The item's value.
— How many items there are in the specified list.
Scratch 2.0 has the following List Boolean block:
— 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 2.0.
Scratch 2.0 has the following six Event Hat Blocks:
— When the flag is clicked, the script activates.
— When the specified key is pressed, the script activates.
— When the sprite is clicked, the script activates.
— When the backdrop switches to the one chosen, the script activates.
— When the first value is greater than the second value, the script activates.
— When the broadcast is received, the script activates.
Scratch 2.0 has the following two Event Stack blocks:
— Sends a broadcast throughout the Scratch program, activating When I Receive () blocks that are set to that broadcast.
— 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 2.0.
Scratch 2.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 2.0 has the following three Control Stack blocks:
— Pauses the script for the amount of time.
— Pauses the script until the condition is true.
— Creates the specified clone.
Scratch 2.0 has the following five Control C blocks:
— A loop that repeats the specified amount of times.
— A loop that will never end.
— Checks the condition so that if the condition is true, the blocks inside it will activate.
— 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.
— A loop that will stop once the condition is true.
Scratch 2.0 has the following two Control Cap blocks:
— 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 20 Sensing blocks in Scratch 2.0.
Scratch 2.0 has the following four Sensing Stack blocks:
— An input box appears — you type the value in and it stores the value in the answer variable.
— Resets the timer.
— Turns the video on.
— Sets the transparency of the video.
Scratch 2.0 has the following five Sensing Boolean blocks:
— The condition for checking if the sprite is touching the mouse-pointer or another sprite.
— The condition for checking if the sprite is touching a specific color.
— The condition for checking if a color on the sprite is touching a specific color.
— The condition for checking if the specified key is being pressed.
— The condition for checking if the mouse is down.
Scratch 2.0 has the following eleven Sensing Reporter blocks:
— The distance from the sprite to the mouse-pointer or another sprite.
— The most recent input with the Ask () And Wait block.
— The mouse-pointer's X position.
— The mouse-pointer's Y position.
— How loud the noise is that the microphone is sensing.
— How much time has passed since the Scratch program was opened or the timer reset.
— The video motion or direction of video motion on an object.
— The X position, Y position, direction, costume, size or volume of the Stage or a sprite.
— The specified time unit selected.
— The number of days since 2000.
— 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 17 Operators blocks in Scratch 2.0.
Scratch 2.0 has the following six 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.
— Joins two conditions.
— Joins two conditions, but they function separately.
— Makes the condition checked if it is false, not true.
Scratch 2.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.
— Picks a random number between the two limits.
— The two values put right next to each other.
— The specified character of the value.
— The length of the value.
— The remainder of the division.
— Rounds the value to the nearest whole number.
— 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.
More blocks
- Main article: More Blocks
More blocks are user-made custom blocks. There are 2 unique kinds of More blocks in Scratch 2.0.
Scratch 2.0 has the following More Modified Hat block:
— Defines a custom block.
Scratch 2.0 has the following More Stack block:
— A custom block.
PicoBoard blocks
- Main article: PicoBoard Blocks
PicoBoard blocks are used to control and sense data from the PicoBoard.
Scratch 2.0 has the 2 following PicoBoard Hat blocks:
Scratch 2.0 has the following PicoBoard Boolean block:
Scratch 2.0 has the following PicoBoard Reporter block:
LEGO WeDo blocks
- Main article: LEGO WeDo Blocks
LEGO WeDo blocks are used to control the LEGO WeDo. They are accessed via the Add an Extension button.
Scratch 2.0 has the following five LEGO WeDo Stack blocks:
Scratch 2.0 has the following two LEGO WeDo Hat blocks:
Scratch 2.0 has the following two LEGO WeDo Reporter blocks:
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 2.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 appears with a few color 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.
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, at which Scratch is designed, 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.
See Also