Discuss Scratch

Wachamacallit
Scratcher
3 posts

Variable reset when green flag clicked

I'm currently working on a game, and I'm trying to make it so all variables reset when the green flag is clicked, but that only happens when the page is reloaded. I've tried making it so the variables set to 0 whenever the flag is clicked, but it still only resets them when the page is reloaded. How do I make it so they reset whenever the flag is clicked?
Karictre
Scratcher
100+ posts

Variable reset when green flag clicked

Please link the project so that it’s easier for us to help you.
MijiGamin1_is_cool
Scratcher
100+ posts

Variable reset when green flag clicked

You should just be able to do:

when green flag clicked
set [variable v] to [0]

or at least that worked for me
Wachamacallit
Scratcher
3 posts

Variable reset when green flag clicked

So I have local variables for a number of different sprites that are the same (each copied via my backpack). Each local variable is called the same thing for every sprite.

I've done this on every sprite:

when green flag clicked
set [ v] to [0]

But for some reason, they rest only reset when the page is reloaded. I have some global variables too, and those work fine, but it's just the local variables that are a problem.

I don't know if you'll be able to see a project that's not shared, but here's the link anyway:

https://scratch.mit.edu/projects/885346257/

Only the top half of the screen in finished by the way. Each tile has an associated global variable. The roads are supposed to change to the right shape by changing costume depending on whether of the surrounding tiles' variables are set to “1” (has a road) or “0” (does not have a road). Each of these global variables are translated to local variables in each sprite called “up”, “down”, “left”, and “right”, so that it is easier to copy the same code to different sprites. There is a “set to 0” block under the “when clicked” block in each of the sprites for each of their associated variables.

The vertical road is supposed to be the default road when there is no other roads around, but when the game is stopped and started again, the roads retain their position from before, even though there is no other roads next to them. I believe the reason this is happening is because the local variables do not reset for some reason (even though they should). If it was the global variables for each tile that wasn't reseting, those tiles would not be empty, so I suspect it is not that.

I have no idea what's going on.
leGuyW0hasremixs4evr
Scratcher
100+ posts

Variable reset when green flag clicked

Wachamacallit wrote:

So I have local variables for a number of different sprites that are the same (each copied via my backpack). Each local variable is called the same thing for every sprite.

I've done this on every sprite:

when green flag clicked
set [ v] to [0]

But for some reason, they rest only reset when the page is reloaded. I have some global variables too, and those work fine, but it's just the local variables that are a problem.

I don't know if you'll be able to see a project that's not shared, but here's the link anyway:

https://scratch.mit.edu/projects/885346257/

Only the top half of the screen in finished by the way. Each tile has an associated global variable. The roads are supposed to change to the right shape by changing costume depending on whether of the surrounding tiles' variables are set to “1” (has a road) or “0” (does not have a road). Each of these global variables are translated to local variables in each sprite called “up”, “down”, “left”, and “right”, so that it is easier to copy the same code to different sprites. There is a “set to 0” block under the “when clicked” block in each of the sprites for each of their associated variables.

The vertical road is supposed to be the default road when there is no other roads around, but when the game is stopped and started again, the roads retain their position from before, even though there is no other roads next to them. I believe the reason this is happening is because the local variables do not reset for some reason (even though they should). If it was the global variables for each tile that wasn't reseting, those tiles would not be empty, so I suspect it is not that.

I have no idea what's going on.
We cannot see a unshared project
Wachamacallit
Scratcher
3 posts

Variable reset when green flag clicked

Ok, it's shared now (temporarily)
Ju2t_Hyper
Scratcher
9 posts

Variable reset when green flag clicked

does it happen when you first view the project cuz i need that
Sammies123333
Scratcher
100+ posts

Variable reset when green flag clicked

Ju2t_Hyper wrote:

does it happen when you first view the project cuz i need that
Please don't Necropost

Powered by DjangoBB