Discuss Scratch

davidvaz1
Scratcher
100+ posts

How to save data and load it in a Scratch Project?

Hello, Scratchers. Please help me with my project here: https://scratch.mit.edu/projects/548505713/
It is a project where you click the Scratch Cat, a Click-Count variable updates, and the Scratch Cat announces the click count.
I want to make a system, where, on click of the ‘Save your progress’ button, the Click-count gets saved in a save file like in this project (which is made by @Zinnea)

Also, on the click of the ‘Load your progress’ button, the Click-Count gets updated when you paste in the save file.

Thank you!

Last edited by davidvaz1 (July 21, 2021 09:45:18)

The_Imaginarium
Scratcher
1000+ posts

How to save data and load it in a Scratch Project?

davidvaz1
Scratcher
100+ posts

How to save data and load it in a Scratch Project?

The_Imaginarium wrote:

https://en.scratch-wiki.info/wiki/Saving_Data
Thanks @The_Imaginarium, but I checked it before writing this forum post, and it did not help much,
ShadowOnTheHorizon
Scratcher
44 posts

How to save data and load it in a Scratch Project?

Just quickly asking, will you need the ability to add more variables to the save code later on? Because if not then it's a really simple task.

Edit: also do you need encoding, because I physically cannot do that.

Last edited by ShadowOnTheHorizon (July 21, 2021 14:16:10)

davidvaz1
Scratcher
100+ posts

How to save data and load it in a Scratch Project?

ShadowOnTheHorizon wrote:

Just quickly asking, will you need the ability to add more variables to the save code later on? Because if not then it's a really simple task.

Edit: also do you need encoding, because I physically cannot do that.
I dont think so; the only variable is a click-count. You can refer to this link for my project: https://scratch.mit.edu/projects/548505713/.

The Load Data button does not work
ShadowOnTheHorizon
Scratcher
44 posts

How to save data and load it in a Scratch Project?

I've noticed that your save code has details like username and time. Is this needed? Because it complicates everything further.

If you don't need them:
Saving:
define save (data)
add ((click count) * (51)) to [save data]
show list [save data]


Loading:
define load (data)
ask [paste save code here] and wait
set [click count] to ((answer) / (51))

Edit: Fixed some small mistakes

Last edited by ShadowOnTheHorizon (July 23, 2021 15:24:44)

davidvaz1
Scratcher
100+ posts

How to save data and load it in a Scratch Project?

ShadowOnTheHorizon wrote:

I've noticed that your save code has details like username and time. Is this needed? Because it complicates everything further.

If you don't need them:
Saving:
define save (data)
add ((click count) * (51)) to [save data]


Loading:
define load (data)
set [click count] to ((answer) / (51))


No, it is just to make a (kind of) save file

I'll try your code.

Thanks, @ShadowOnTheHorizon!
davidvaz1
Scratcher
100+ posts

How to save data and load it in a Scratch Project?

ShadowOnTheHorizon wrote:

I've noticed that your save code has details like username and time. Is this needed? Because it complicates everything further.

If you don't need them:
Saving:
define save (data)
add ((click count) * (51)) to [save data]


Loading:
define load (data)
set [click count] to ((answer) / (51))

But, why are you using ‘51’ only? Can this number be changed to say, 35 or something?
ShadowOnTheHorizon
Scratcher
44 posts

How to save data and load it in a Scratch Project?

Yep, 51 is just a random number I chose.
davidvaz1
Scratcher
100+ posts

How to save data and load it in a Scratch Project?

ShadowOnTheHorizon wrote:

Yep, 51 is just a random number I chose.
Thanks so much!


Will close the topic

Btw, did you know that this is my first forum post?

Powered by DjangoBB