Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I make a savecode on my game?
- Scratcher0914
-
Scratcher
38 posts
How do I make a savecode on my game?
Hello, If you're reading this, can you help me with my code?
I have a game that doesn't delete the progress after clicking the flag, and that made the next person playing the game will effect used from the one before.
So please tell me how to make a save code…
Thanks, @Scratcher0914
I have a game that doesn't delete the progress after clicking the flag, and that made the next person playing the game will effect used from the one before.
So please tell me how to make a save code…
Thanks, @Scratcher0914
- ggenije2
-
Scratcher
100+ posts
How do I make a savecode on my game?
Look at this tutorial:
https://scratch.mit.edu/projects/584878038/
https://scratch.mit.edu/projects/584878038/
- lion334
-
Scratcher
100+ posts
How do I make a savecode on my game?
Hello, If you're reading this, can you help me with my code?Tip: Don't do it. I made it for my new game (which is linked in my signature), and even for me it's really hard (and I'd say am “experienced” on scratch!)
I have a game that doesn't delete the progress after clicking the flag, and that made the next person playing the game will effect used from the one before.
So please tell me how to make a save code…
Thanks, @Scratcher0914
Short Summary of what you would have to do:
1. You'd have to convert a username to only Numbers (is hard, DO NOT DO IT!)
2. You have to convert your score & Items to only Numbers
3. You have to connect the outputs of the 1st and 2nd step and save this on a
(☁ scloud variable)4. You have to make a system that converts these Numbers BACK into letters & Numbers
5. You need to detect if the Person currently playing has a Cloud Variable Assigned
6. If yes, it needs to wipe the items and replace it with the ones you uplaoded
7. If no, then it shouldn't do anything
8. You need to say which person gets a cloud variable, using a System that ranks the Players and the Top Ten get a Cloud Variable Save Slot.
OH YOU DON' BELIEVE ME?
There you go.

- idkhow2type
-
Scratcher
100+ posts
How do I make a savecode on my game?
i will try to not be rude but here we goHello, If you're reading this, can you help me with my code?Tip: Don't do it. I made it for my new game (which is linked in my signature), and even for me it's really hard (and I'd say am “experienced” on scratch!)
I have a game that doesn't delete the progress after clicking the flag, and that made the next person playing the game will effect used from the one before.
So please tell me how to make a save code…
Thanks, @Scratcher0914
Short Summary of what you would have to do:
1. You'd have to convert a username to only Numbers (is hard, DO NOT DO IT!)
2. You have to convert your score & Items to only Numbers
3. You have to connect the outputs of the 1st and 2nd step and save this on a(☁ scloud variable)4. You have to make a system that converts these Numbers BACK into letters & Numbers
5. You need to detect if the Person currently playing has a Cloud Variable Assigned
6. If yes, it needs to wipe the items and replace it with the ones you uplaoded
7. If no, then it shouldn't do anything
8. You need to say which person gets a cloud variable, using a System that ranks the Players and the Top Ten get a Cloud Variable Save Slot.
OH YOU DON' BELIEVE ME?
There you go.
first, encoders and decoders for cloud variables arent that hard to make, and there are plenty of projects with “engines” dedicated for this so you don't even have to make it yourself if you don't want to.
second, i have seen plenty of projects vastly more complicated than this. there have been ray tracers, “operating systems”, and authentication systems all made using scratch, people have pushed this platform so so far its incomprehensible, a multiplayer project using cloud variables is nothing
third, the original idea technically doesnt even involve real time multiplayer, making it quite simpler than youre imagining
finally, you shouldn't discourage others to attempt at making something. yes it might be hard and they might fail, but it's still a learning experience
again, I don't want to appear rude, but that's my opinion, good luck on your journey of being '“experienced” on scratch!'
- lion334
-
Scratcher
100+ posts
How do I make a savecode on my game?
i will try to not be rude but here we goHello, If you're reading this, can you help me with my code?Tip: Don't do it. I made it for my new game (which is linked in my signature), and even for me it's really hard (and I'd say am “experienced” on scratch!)
I have a game that doesn't delete the progress after clicking the flag, and that made the next person playing the game will effect used from the one before.
So please tell me how to make a save code…
Thanks, @Scratcher0914
Short Summary of what you would have to do:
1. You'd have to convert a username to only Numbers (is hard, DO NOT DO IT!)
2. You have to convert your score & Items to only Numbers
3. You have to connect the outputs of the 1st and 2nd step and save this on a(☁ scloud variable)4. You have to make a system that converts these Numbers BACK into letters & Numbers
5. You need to detect if the Person currently playing has a Cloud Variable Assigned
6. If yes, it needs to wipe the items and replace it with the ones you uplaoded
7. If no, then it shouldn't do anything
8. You need to say which person gets a cloud variable, using a System that ranks the Players and the Top Ten get a Cloud Variable Save Slot.
OH YOU DON' BELIEVE ME?
There you go.
first, encoders and decoders for cloud variables arent that hard to make, and there are plenty of projects with “engines” dedicated for this so you don't even have to make it yourself if you don't want to.
second, i have seen plenty of projects vastly more complicated than this. there have been ray tracers, “operating systems”, and authentication systems all made using scratch, people have pushed this platform so so far its incomprehensible, a multiplayer project using cloud variables is nothing
third, the original idea technically doesnt even involve real time multiplayer, making it quite simpler than youre imagining
finally, you shouldn't discourage others to attempt at making something. yes it might be hard and they might fail, but it's still a learning experience
again, I don't want to appear rude, but that's my opinion, good luck on your journey of being '“experienced” on scratch!'
Uhh I mean if it's that easy, then do it

- musicROCKS013
-
Scratcher
1000+ posts
How do I make a savecode on my game?
They said save code, not cloud saving.Hello, If you're reading this, can you help me with my code?Tip: Don't do it. I made it for my new game (which is linked in my signature), and even for me it's really hard (and I'd say am “experienced” on scratch!)
I have a game that doesn't delete the progress after clicking the flag, and that made the next person playing the game will effect used from the one before.
So please tell me how to make a save code…
Thanks, @Scratcher0914
-snip-
- TheComplicatedCodes
-
Scratcher
8 posts
How do I make a savecode on my game?
Its complex and challenging, saved for experts. The basics are that a code is broken up into several parts. For our example, I will use 3 parts.
The code is best used with only numbers. Build a code reader that detects a “00” in the code. Once it identifies the seperator string (00)
it reads the next part. Numbers are read and transferred into actual data such as in-game currency. Create a character list to piece together strings of characters that can be transferred into all sorts of information.
I am not the best person on this topic, but reply with a quote and I will reply back if you have questions.
The code is best used with only numbers. Build a code reader that detects a “00” in the code. Once it identifies the seperator string (00)
it reads the next part. Numbers are read and transferred into actual data such as in-game currency. Create a character list to piece together strings of characters that can be transferred into all sorts of information.
I am not the best person on this topic, but reply with a quote and I will reply back if you have questions.
- Trixie987
-
Scratcher
100+ posts
How do I make a savecode on my game?
If you still need help follow this example.
First, you need to create a code. I have put variables in there for examples. You do not have to have the high scrore or currency or three variables. Put in what you want to save.
First, you need to create a code. I have put variables in there for examples. You do not have to have the high scrore or currency or three variables. Put in what you want to save.
define Create Save CodeNow for a load system
set [code v] to (join (currency) (join [&] ( join (High score) (join [&] ( another variable)))))
define Load CodeContinue to do this for all your variables you have in the code except for the last one do..
set [X] to [1]
repeat until ((letter (X) of (code)) = [&])//You can change 'code' to 'answer' if you ask what the code is in the project
set [currency v] to (join (currency) (letter (X) of (code)))// This sets all the digits until & to the currency
change [X v] by [1]
end
change [X v] by [1]// To Skip over &
repeat until ((letter (X) of (code)) = [])//Blank means the end of the code
set [variable v] to (join (variable) (letter (X) of (code))
change [X v] by [1]
end
Last edited by Trixie987 (June 14, 2022 22:40:38)
- GIitchInTheMatrix
-
Scratcher
1000+ posts
How do I make a savecode on my game?
here's one with encoding and decoding while offline, which can be used for most games:
https://scratch.mit.edu/projects/705294063/
https://scratch.mit.edu/projects/705294063/
- Scratcher0914
-
Scratcher
38 posts
How do I make a savecode on my game?
Thanks for letting me know!
However, some codes seem to not work.
(P.S: Please don't say “it's impossible” or “Don't do it”.
Thank you very much!
However, some codes seem to not work.
(P.S: Please don't say “it's impossible” or “Don't do it”.
Thank you very much!
- idkhow2type
-
Scratcher
100+ posts
How do I make a savecode on my game?
#5here's a project that can retrieve its comments and display them in the project. this project uses gets the comments using scratch's API, encodes them, saves them on cloud variables, decodes them in scratch and finally displays them
a lot of people have answered this topic but @Scratcher0914 seems to still haven't figured it out so I'll break it down step by step
if I understand the problem correctly, @Scratcher0914 wants to create a project that changes for every visit, a very simple example would look like
when green flag clickedthis is a very simple clicker game that increments by a different amount depending on the current state of the cloud variable
set [amount v] to (☁ score)
forever
say (☁ score)
end
when this sprite clicked
change [☁ score v] by (amount)
the special thing with this idea is that it isn't a multiplayer project, therefore, we don't need to create a slot system.
Encoder and decoder
because we want to store a lot of complex data, we need to create a text encoder and decoder as cloud variables can only store digits.
the first step in doing this is to create a list of allowed characters, an alphabet if you will
for this step, a lot of people create a big stack of blocks with the sole purpose of initialising the alphabet. in my opinion, this is overkill. what we will do is create a list and manually input our alphabet once. depending on your application, the alphabet might look different, in this example, I will support all ascii characters.
- create a list called “ALPHABET” (or whatever idc)
- using the “+” button at the bottom left of the list, add all characters you want to support (these can be in any order). for your convenience, here's a text file with all ascii characters to import into your list*
- that's it. however, do note that from now on, never use any blocks that can modify this list
- the first 9 items are intentionally blank, don't modify them
- the 10th list item is a space, don't modify it
- the double quote and comma have a backslash (\) in front. this is to prevent some problems with scratch when importing the list. remove the backslash after importing the list
the encoder will simply loop through every character, look up their index (position) in the alphabet, and add that index to the encoded string
one important thing about this is every encoded character needs to have the same length for the decoder to work, in our case every character uses 2 digits. the first 9 characters of our alphabet are empty for the convenience of encoding every character 2 digits long
here's the code for the encoder
define Encode(text)using this custom block, we can encode any piece of text into digits to save into cloud variables.
set [encoded v] to []
set [i v] to [1]
repeat (length of (text)) // loop through the text
set [encoded v] to (join (encode) (item # of (letter (i) of (text)) [ALPHABET v] :: list)) // join encoded with the index of the current character
if <not <[ALPHABET v] contains (letter (i) of (text)) ?>> then // if the character isn't in the alphabet, join encoded with 99
set [encoded v] to (join (encode) [99])
end
change [i v] by (1)
if <(i) > [128]> then // stop script and create warning if text longer than 128 letters, as cloud variables can only store 256 digits
say [Warning: text longer than 128 characters]
stop [this script v]
end
end
to read this data, we need to create a decoder. the decoder will do the exact opposite of the encoder, it will loop through 2 digits at a time and convert them back into letters
here's the code for the decoder
define Decode(encoded)
set [decoded v] to []
set [i v] to [1]
repeat ((length of (encoded)) / (2)) // loop through the encoded text 2 digits at a time
set [char code v] to (join (letter (i) of (encoded)) (letter ((i) + (1)) of (encoded))) // the current 2 digits to decode
if <(char code) = [99]> then
set [decoded v] to (join (decoded) [?]) // if the character isn't in the alphabet, add "?" to decoded
else
set [decoded v] to (join (decoded) (item (char code) of [ALPHABET v] :: list)) // else add the character to decoded
end
change [i v] by (2)
end
Encode and decode data with comma-separated string
using the encoder and decoder, you can encode data to store on cloud variables, and then decode to process the data
but how do we create data suitable for encoding and decoding?
one way to do this is with a comma-separated string. this means we will have a piece of text with multiple values, each value separated by a comma.
for this example, let's say we need to store the player's x and y positions. when encoding, we will do something like
Encode(join (join (x position) [,]) (y position)) :: custombut decoding this data is more complicated. we need to extract the x and y positions into separate values when decoding them. for this, we will need a custom block that can split a string by a separator.
set [☁ data v] to (encoded)
define Split (text) by (separator)with this block, we can decode the cloud variable to a comma-separated string, and then split that string into separate values that can be used in the project
delete all of [split v] :: list
set [current item v] to []
set [i v] to [1]
repeat (length of (text))
if <(letter (i) of (text)) = (separator)> then
add (current item) to [lsplit v]
set [current item v] to []
else
set [current item v] to (join (current item) (letter (i) of (text)))
end
change [i v] by (1)
end
now, our decoding script will look like
Decode(☁ data) :: custom
Split (☁ data) by [,] :: custom
go to x: (item (1) of [split v] :: list) y: (item (2) of [split v] :: list)
Final notes
- I haven't tested any of the custom blocks so they may not work, reply if that's the case
- This took way too long to write so sorry if there are any grammar errors/spelling errors/typos
Last edited by idkhow2type (June 15, 2022 10:41:30)
- samurai_master123
-
Scratcher
100+ posts
How do I make a savecode on my game?
For the progress you can use this:
I did this example with some random things. Repeat for everything else with any other letter.
(join (join (join (join [G] (Gems)) [L]) (Level)) (join [C] (Coins)))
repeat until <(CurrentDigit) = [G]>
set [Gems v] to (join (Gems) (letter (CurrentDigit) of (SaveFile))) //Basically just building digit by digit.
change [CurrentDigit v] by (1)
end
change [CurrentDigit v] by (1) //So it can go to the digit AFTER the G
I did this example with some random things. Repeat for everything else with any other letter.
Last edited by samurai_master123 (June 16, 2022 13:01:33)
- Discussion Forums
- » Help with Scripts
-
» How do I make a savecode on my game?