Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Save code
- BenAndMe
- Scratcher
100+ posts
Save code
I am using this method for make a save code but when I do it any 3, 2 or 1 digit numbers it puts a zero infront of it which messes up my score counter, heres the code that I'm using:
https://scratch.mit.edu/projects/24179776/
any help needed!
https://scratch.mit.edu/projects/24179776/
any help needed!
Last edited by BenAndMe (Jan. 2, 2018 20:45:59)
- Haz-_-
- Scratcher
500+ posts
Save code
Try using “cloud data” I am using this method for make a save code but when I do it any 3, 2 or 1 digit numbers it puts a zero infront of it which messes up my score counter, heres the code that I'm using:
https://scratch.mit.edu/projects/24179776/
any help needed!
that might work
continue this hashtag if you live in australia [img]http://u.cubeupload.com/rabbitcarrots/FEDB1435D41540BFB9FB.jpeg[/img] is the image code xD oh and btw this siggy is from @Hellounicorns2 :cool:
- MrGigabyte
- Scratcher
94 posts
Save code
You can put a separating character between each item in the save code.
So for example if you wanted to save the score, coins, and lives,
and if score was 120, coins was 48, and lives was 3,
you would join all the variables and stuff together in order.
Then, the save code would be 120:48:3. The player would then copy and save this save code.
To load it, you would break the save code into the 3 parts at the colons (or whatever separating character)
with some code like this https://scratch.mit.edu/projects/192763736/
Then you would have what the 3 variables were when the player saved. (in a list)
Just reset all the variables back to what the save code separating code gave out.
You can even “encode” the numbers so it is harder for the players to change the stuff in the save code.
Replacing every number with a letter (so it's more confusing to change)
So 0 would be a, 1 would be b, and so on (you can use any letter to replace a digit, but make sure each number corresponds to a different letter)
Then check what the letters were and replace them back with numbers when loading.
So 1001 would be abba or something (120:48:3 save code would be bca:ei:d - harder to mess with)
Here's a game that i used save codes in to save the entire state of the player's city, their goals, currencies, stats, settings, and more https://scratch.mit.edu/projects/178912518/
(I'm following this thread)
So for example if you wanted to save the score, coins, and lives,
and if score was 120, coins was 48, and lives was 3,
you would join all the variables and stuff together in order.
Then, the save code would be 120:48:3. The player would then copy and save this save code.
To load it, you would break the save code into the 3 parts at the colons (or whatever separating character)
with some code like this https://scratch.mit.edu/projects/192763736/
Then you would have what the 3 variables were when the player saved. (in a list)
Just reset all the variables back to what the save code separating code gave out.
You can even “encode” the numbers so it is harder for the players to change the stuff in the save code.
Replacing every number with a letter (so it's more confusing to change)
So 0 would be a, 1 would be b, and so on (you can use any letter to replace a digit, but make sure each number corresponds to a different letter)
Then check what the letters were and replace them back with numbers when loading.
So 1001 would be abba or something (120:48:3 save code would be bca:ei:d - harder to mess with)
Here's a game that i used save codes in to save the entire state of the player's city, their goals, currencies, stats, settings, and more https://scratch.mit.edu/projects/178912518/
(I'm following this thread)
Last edited by MrGigabyte (Jan. 10, 2018 02:10:36)
- Discussion Forums
- » Help with Scripts
- » Save code