Discuss Scratch

peo9281
Scratcher
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:
delete (all v) of [my list v]
add (startingvalue) to [list v]
And then these two for any other time you need to change it.
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
Scratcher
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
Scratcher
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
Scratcher
30 posts

Whats the point of variables?

ThatOneWeirdDude wrote:

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
Well you can just import your cloud variable into your list and keep it there like this:
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
Scratcher
1000+ posts

Whats the point of variables?

peo9281 wrote:

ThatOneWeirdDude wrote:

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
Well you can just import your cloud variable into your list and keep it there like this:
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
ok yea, but thats just adding extra steps… just use variables
peo9281
Scratcher
30 posts

Whats the point of variables?

hi875230163394 wrote:

peo9281 wrote:

ThatOneWeirdDude wrote:

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
Well you can just import your cloud variable into your list and keep it there like this:
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
ok yea, but thats just adding extra steps… just use variables
Maybe your right! I never thought about it like that…
ThatOneWeirdDude
Scratcher
1000+ posts

Whats the point of variables?

peo9281 wrote:

ThatOneWeirdDude wrote:

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
Well you can just import your cloud variable into your list and keep it there like this:
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
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.
peo9281
Scratcher
30 posts

Whats the point of variables?

ThatOneWeirdDude wrote:

peo9281 wrote:

ThatOneWeirdDude wrote:

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
Well you can just import your cloud variable into your list and keep it there like this:
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
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.
Ok now I know why!
musicROCKS013
Scratcher
1000+ posts

Whats the point of variables?

peo9281 wrote:

hi875230163394 wrote:

peo9281 wrote:

ThatOneWeirdDude wrote:

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
Well you can just import your cloud variable into your list and keep it there like this:
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
ok yea, but thats just adding extra steps… just use variables
Maybe your right! I never thought about it like that…
notice, that you are still using a variable in this script
Chiroyce
Scratcher
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.

peo9281 wrote:

Whats the point of variables if lists can store the same thing?
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.

Last edited by Chiroyce (March 1, 2022 04:29:21)

R_Ravenclaw
Scratcher
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
Scratcher
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.
k0d3rrr
Scratcher
1000+ posts

Whats the point of variables?

Variables are easier to understand than lists. No complicated answer, just a simple answer.
peo9281
Scratcher
30 posts

Whats the point of variables?

Ohhh ok

musicROCKS013 wrote:

peo9281 wrote:

hi875230163394 wrote:

peo9281 wrote:

ThatOneWeirdDude wrote:

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
Well you can just import your cloud variable into your list and keep it there like this:
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
ok yea, but thats just adding extra steps… just use variables
Maybe your right! I never thought about it like that…
notice, that you are still using a variable in this script
I thought I already said hes right?
peo9281
Scratcher
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
Scratcher
1000+ posts

Whats the point of variables?

peo9281 wrote:

(#15)
I think I might close this topic later cause I just realized why
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.

Powered by DjangoBB