Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How To Sense Resets
- mellow_turtle
-
Scratcher
4 posts
How To Sense Resets
How do you make it so that a project can sense how many times the flag has been pressed? Like if you want something to appear the first time you click play on a game but if you click the flag again the same thing will not appear. Also, How do you make it so that you can achieve a checkpoint or unlock something, and then if you click the flag again, you will still have the item unlocked or still be at the checkpoint? I mean in the same tab, not multiple windows. I know That's impossible. Can someone please help?
- Scratch-Minion
-
Scratcher
1000+ posts
How To Sense Resets
In Scratch project data keep their values between project runs provided you do not exit the page.
So set some values in your project before you share it.
eg.
NB. Create the above code as an isolated script that is not run when the Green Flag is clicked.
You must run this script before the project is shared to reset and initialize the values.
Then when the project is run:
Also when you reach a checkpoint, update Last Checkpoint Reached.
Edit: ninja'd - I think I write too much
So set some values in your project before you share it.
eg.
set [First Run v] to [true]
set [Last Checkpoint Reached v] to [0]
NB. Create the above code as an isolated script that is not run when the Green Flag is clicked.
You must run this script before the project is shared to reset and initialize the values.
Then when the project is run:
when green flag clicked
if <(First Run) = [true]> then
... // Do the first time only stuff
end
set [First Run v] to [false]
Also when you reach a checkpoint, update Last Checkpoint Reached.
Edit: ninja'd - I think I write too much

Last edited by Scratch-Minion (Oct. 30, 2020 09:26:43)
- Discussion Forums
- » Help with Scripts
-
» How To Sense Resets