Discuss Scratch

CEOofApple
Scratcher
38 posts

Saving Data

Hi everyone CEOofApple here. I was just wondering about Saving Data in Scratch. I am very confused of the concept, and I was just wondering what code would I put in if I wanted to save an RPG game, like Pokémon or something.


Thanks,

-CEOofApple

“If today were the last day of your life, would you want to do what you are about to do today?” - Steve Jobs
Check out my profile!
Follow Me!
Kenichi10B
Scratcher
74 posts

Saving Data

Pretty complicated, but the idea is that you have key components (for an RPG, things like money, health, etc.) stored somehow, and when you load the game, it will basically set up the game using the stored values. Basically, imagine that when you save your game, all your game info is stored somehow (For scratch, either a cloud variable or list), and when you ‘load’ your game, it doesn't actually ‘remember’ your progress, it just “starts a new game that's exactly the same as what you saved”.

For saving, it depends on if you want the data to be accessible even on refresh, or if you don't mind it being cleared when a user refreshes.

For lists (This method will clear ALL your save data if the user reloads the page):
Let's say you have 3 variables, money, health, and points. When you save, use this script:
replace item (1 v) of [savestuff v] with [Money]
replace item (2 v) of [savestuff v] with [Health]
replace item (3 v) of [savestuff v] with [Points]

When you load, use this script:
set [Money v] to (item (1 v) of [savestuff v])
set [Health v] to (item (2 v) of [savestuff v])
set [Points v] to (item (3 v) of [savestuff v])
See the point? It just sets stuff back to how it is when you saved. To see it in action, here's a link: http://scratch.mit.edu/projects/20985527/

For cloud variables:
To manage everyone's data seperately on a cloud variable, it is EXTREMELY COMPLICATED. Luckily, Griffpatch has already saved the day on that problem though; he's made a demo that works with what you would want. Here's the link to that: http://scratch.mit.edu/projects/12503640/
CEOofApple
Scratcher
38 posts

Saving Data

Kenichi10B wrote:

Pretty complicated, but the idea is that you have key components (for an RPG, things like money, health, etc.) stored somehow, and when you load the game, it will basically set up the game using the stored values. Basically, imagine that when you save your game, all your game info is stored somehow (For scratch, either a cloud variable or list), and when you ‘load’ your game, it doesn't actually ‘remember’ your progress, it just “starts a new game that's exactly the same as what you saved”.

For saving, it depends on if you want the data to be accessible even on refresh, or if you don't mind it being cleared when a user refreshes.

For lists (This method will clear ALL your save data if the user reloads the page):
Let's say you have 3 variables, money, health, and points. When you save, use this script:
replace item (1 v) of [savestuff v] with [Money]
replace item (2 v) of [savestuff v] with [Health]
replace item (3 v) of [savestuff v] with [Points]

When you load, use this script:
set [Money v] to (item (1 v) of [savestuff v])
set [Health v] to (item (2 v) of [savestuff v])
set [Points v] to (item (3 v) of [savestuff v])
See the point? It just sets stuff back to how it is when you saved. To see it in action, here's a link: http://scratch.mit.edu/projects/20985527/

For cloud variables:
To manage everyone's data seperately on a cloud variable, it is EXTREMELY COMPLICATED. Luckily, Griffpatch has already saved the day on that problem though; he's made a demo that works with what you would want. Here's the link to that: http://scratch.mit.edu/projects/12503640/

Yeah, but due to Cloud Data Limits , GriffPatch's Cloud Data Demo does not work.

“If today were the last day of your life, would you want to do what you are about to do today?” - Steve Jobs
Check out my profile!
Follow Me!
Kenichi10B
Scratcher
74 posts

Saving Data

CEOofApple wrote:

Kenichi10B wrote:

Pretty complicated, but the idea is that you have key components (for an RPG, things like money, health, etc.) stored somehow, and when you load the game, it will basically set up the game using the stored values. Basically, imagine that when you save your game, all your game info is stored somehow (For scratch, either a cloud variable or list), and when you ‘load’ your game, it doesn't actually ‘remember’ your progress, it just “starts a new game that's exactly the same as what you saved”.

For saving, it depends on if you want the data to be accessible even on refresh, or if you don't mind it being cleared when a user refreshes.

For lists (This method will clear ALL your save data if the user reloads the page):
Let's say you have 3 variables, money, health, and points. When you save, use this script:
replace item (1 v) of [savestuff v] with [Money]
replace item (2 v) of [savestuff v] with [Health]
replace item (3 v) of [savestuff v] with [Points]

When you load, use this script:
set [Money v] to (item (1 v) of [savestuff v])
set [Health v] to (item (2 v) of [savestuff v])
set [Points v] to (item (3 v) of [savestuff v])
See the point? It just sets stuff back to how it is when you saved. To see it in action, here's a link: http://scratch.mit.edu/projects/20985527/

For cloud variables:
To manage everyone's data seperately on a cloud variable, it is EXTREMELY COMPLICATED. Luckily, Griffpatch has already saved the day on that problem though; he's made a demo that works with what you would want. Here's the link to that: http://scratch.mit.edu/projects/12503640/

Yeah, but due to Cloud Data Limits , GriffPatch's Cloud Data Demo does not work.

Yeah… Unfortunately due to variable limits, you can't save infinite data on a cloud variable, but you should be able to save a good 50-150 people's data with one variable. Good luck on your project; feel free to shoot a comment on my profile if you need anything else!

Powered by DjangoBB