Variables blocks are the blocks that hold variables and lists. The variable blocks are color-coded orange, and the list blocks are color-coded dark red. There are 5 Variables blocks and 11 list blocks in Scratch 3.0.
1. Set [variable] to [value] block
2. Change [variable] by [value] block
3. Show variable [variable] block
4. Hide variable [variable] block
5. [variable] block
Arun: Now let’s learn about variable blocks. These blocks are very useful for holding and manipulating data.
Raj: What are the different types of variable blocks?
Arun: Scratch 3.0 has four Variables Stack blocks and one Variables Reporter block. Let’s go through each one.
Arun: The first block is the Set [variable] to [value]
block. This block sets the specified variable to the amount.
Raj: So, if I want to set my score to 0 at the beginning of a game, I can use this block.
Arun: Exactly! Next is the Change [variable] by [value]
block. This block changes the specified variable by the amount.
Raj: I see, so if I want to increase the score by 1 whenever a player earns a point, I can use this block.
Arun: Yes, that’s right. The next two blocks are for showing and hiding the variable’s Stage Monitor. These are Show variable [variable]
and Hide variable [variable]
blocks.
Raj: So I can control when the variable is visible on the stage.
Arun: Exactly. Finally, we have the [variable]
block. This block reports the variable’s value.
Raj: This block is useful for checking the value of the variable at any point in the script.
Arun: Correct! These blocks are very useful for managing data in your Scratch projects.
Raj: Thanks, Arun. This makes it easier to understand how to use variables in Scratch.
Arun: You’re welcome! Next time, we’ll learn about list blocks and how to use them in your projects.