Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » Whats the point of variables?
- peo9281
-
30 posts
Whats the point of variables?
I've been wondering this for a very long time.
Whats the point of variables if lists can store the same thing?
If you wish for a variable that stores 2 things at the same time then no variable is gonna be able to do that. But when you have a list you can store 2 things at the same time.
And also, if you wanted a list to store 1 value you can use these 2 blocks:
Whats the point of variables if lists can store the same thing?
If you wish for a variable that stores 2 things at the same time then no variable is gonna be able to do that. But when you have a list you can store 2 things at the same time.
And also, if you wanted a list to store 1 value you can use these 2 blocks:
delete (all v) of [my list v]And then these two for any other time you need to change it.
add (startingvalue) to [list v]
replace item (1 v) of [my list v] with [value]
(item (1 v) of [my list v] :: list)
Last edited by peo9281 (March 1, 2022 00:10:15)
- hi875230163394
-
1000+ posts
Whats the point of variables?
uses less blocks and can be used to display a score, besides lists can be a bit intimidating for new users to learn
- ThatOneWeirdDude
-
1000+ posts
Whats the point of variables?
Triggering events, cloud data, easier to use for storing certain types of data, less code required are just the ones i can name off the top of my head
- peo9281
-
30 posts
Whats the point of variables?
cloud data, easier to use for storing certain types of data, less code required are just the ones i can name off the top of my headWell you can just import your cloud variable into your list and keep it there like this: Triggering events,
when green flag clicked
forever
if <not <(☁ score) = (item (1 v) of [my list v] :: list)>> then
replace item (1 v) of [list v] with (☁ score)
end
end
Last edited by peo9281 (March 1, 2022 00:23:29)
- hi875230163394
-
1000+ posts
Whats the point of variables?
ok yea, but thats just adding extra steps… just use variablescloud data, easier to use for storing certain types of data, less code required are just the ones i can name off the top of my headWell you can just import your cloud variable into your list and keep it there like this: Triggering events,when green flag clicked
forever
if <not <(☁ score) = (item (1 v) of [my list v] :: list)>> then
replace item (1 v) of [list v] with (☁ score)
end
end
- peo9281
-
30 posts
Whats the point of variables?
Maybe your right! I never thought about it like that…ok yea, but thats just adding extra steps… just use variablescloud data, easier to use for storing certain types of data, less code required are just the ones i can name off the top of my headWell you can just import your cloud variable into your list and keep it there like this: Triggering events,when green flag clicked
forever
if <not <(☁ score) = (item (1 v) of [my list v] :: list)>> then
replace item (1 v) of [list v] with (☁ score)
end
end
- ThatOneWeirdDude
-
1000+ posts
Whats the point of variables?
The scratch team does not remove blocks because their is a workaround to it, Scratch is supposed to be easy for everyone to use, so variables are a way of easing the coding process.cloud data, easier to use for storing certain types of data, less code required are just the ones i can name off the top of my headWell you can just import your cloud variable into your list and keep it there like this: Triggering events,when green flag clicked
forever
if <not <(☁ score) = (item (1 v) of [my list v] :: list)>> then
replace item (1 v) of [list v] with (☁ score)
end
end
I still think that part where they use less blocks is true tho
- peo9281
-
30 posts
Whats the point of variables?
Ok now I know why!The scratch team does not remove blocks because their is a workaround to it, Scratch is supposed to be easy for everyone to use, so variables are a way of easing the coding process.cloud data, easier to use for storing certain types of data, less code required are just the ones i can name off the top of my headWell you can just import your cloud variable into your list and keep it there like this: Triggering events,when green flag clicked
forever
if <not <(☁ score) = (item (1 v) of [my list v] :: list)>> then
replace item (1 v) of [list v] with (☁ score)
end
end
I still think that part where they use less blocks is true tho
- musicROCKS013
-
1000+ posts
Whats the point of variables?
notice, that you are still using a variable in this scriptMaybe your right! I never thought about it like that…ok yea, but thats just adding extra steps… just use variablescloud data, easier to use for storing certain types of data, less code required are just the ones i can name off the top of my headWell you can just import your cloud variable into your list and keep it there like this: Triggering events,when green flag clicked
forever
if <not <(☁ score) = (item (1 v) of [my list v] :: list)>> then
replace item (1 v) of [list v] with (☁ score)
end
end
- Chiroyce
-
1000+ posts
Whats the point of variables?
Store data that can change over time - a very good example for this, and popularly used in Scratch is for storing the player's score in a game. In a catch game, whenever they catch something, they can increase the score by one. After the game has ended, the score can be displayed to the user.
Variables are easier to use and name - if you want to use lists the exact same way as variables, you have to code a bit of logic to make lists work the same way. If you use variables, no setup is required. Which is easier for beginner Scratch users. Whats the point of variables if lists can store the same thing?
Last edited by Chiroyce (March 1, 2022 04:29:21)
- R_Ravenclaw
-
100+ posts
Whats the point of variables?
Everything that has been said, but also Scratch is supposed to be an introduction to coding, and variables are a very important aspect of most programming languages. So it is good to help beginners understand the concept.
- NMario84
-
1000+ posts
Whats the point of variables?
Yea, the way I see it, using lists over variables will decrease the amount of mess of variable objects you create in your project, where all the variables can be stored in to 1 single list. 
The only downside is that variables (over lists) have the option for sliders to change the value by sliding the bar, where as lists can not do this. Though you could potentially build your own slider if needed.
But yea, I'm trying to work on a variable-less game, where everything is stored in a list to optimize the amount of variable objects. But when I need to use cloud variables, then I just use those separately from the list values.
But I do agree that lists are somewhat more advanced, but a possible workaround instead of using variables.

The only downside is that variables (over lists) have the option for sliders to change the value by sliding the bar, where as lists can not do this. Though you could potentially build your own slider if needed.
But yea, I'm trying to work on a variable-less game, where everything is stored in a list to optimize the amount of variable objects. But when I need to use cloud variables, then I just use those separately from the list values.
But I do agree that lists are somewhat more advanced, but a possible workaround instead of using variables.
- k0d3rrr
-
1000+ posts
Whats the point of variables?
Variables are easier to understand than lists. No complicated answer, just a simple answer.
- peo9281
-
30 posts
Whats the point of variables?
Ohhh ok
I thought I already said hes right?notice, that you are still using a variable in this scriptMaybe your right! I never thought about it like that…ok yea, but thats just adding extra steps… just use variablescloud data, easier to use for storing certain types of data, less code required are just the ones i can name off the top of my headWell you can just import your cloud variable into your list and keep it there like this: Triggering events,when green flag clicked
forever
if <not <(☁ score) = (item (1 v) of [my list v] :: list)>> then
replace item (1 v) of [list v] with (☁ score)
end
end
- peo9281
-
30 posts
Whats the point of variables?
I think I might close this topic later cause I just realized why
Last edited by peo9281 (March 1, 2022 20:53:16)
- ScratchCat1038
-
1000+ posts
Whats the point of variables?
(#15)If you want to close your topic sooner, you can click the report button on the first post and enter “resolved, close this” or something along those lines.
I think I might close this topic later cause I just realized why
- Discussion Forums
- » Questions about Scratch
-
» Whats the point of variables?