Discuss Scratch

Izzy989
Scratcher
7 posts

Save codes

I just can't figure out how to make a save code no matter how hard I try! Can somebody please explain it to me then give me an example?
whenclickedifthirstythensaydrink waterfor2secsaskwhy?andwaitsayBecause you'll die of dehydration, otherwisefor2secs
Non-Generic_Cube
Scratcher
6 posts

Save codes

Well, I don't think I can explain it, but I made a save code using a tutorial. Just search up ‘save code tutorial ’ on Scratch, hope that will help!
Also, if you wanna make more complex save codes that are harder to cheat on, search up ‘encoding and decoding’

Last edited by Non-Generic_Cube (Sept. 23, 2024 17:17:37)

bombardingppl
Scratcher
500+ posts

Save codes

A lot of save codes are when you join all of the data sets into a single string and be able to decode it into data again when they load the code. Here's an example.

Clicker game
clicks: 100
clicks per second: 5

The save code would look something like “100 5” or maybe “100|5”. You usually want to avoid the one with the spaces, because some data values might include spaces, let's say something like, “diamond clicker”, and the save code might look like “100 5 diamond clicker”. Now this is a problem because when you decode the code, it might think that there are 4 values instead of three, thinking that the “diamond” and “clicker” are different. So it's a good idea to use a separator that will never appear in your data.

Now let's use the “|” to separate our data. This is what our code might look like

addclickstosave codeaddclickspersecondtosave code

setiterationto1iteration means the number showing how many times you repeated somethingsetsave codetothis is blank, no space.repeatlengthofsave codesetsave codetojoinsavecodeitemiterationofsave codechangeiterationby1

decoding is very difficult and if you'd like I'll show you how that is done if you let me know. For now, this is a way of encoding data.
bsteichman
Scratcher
500+ posts

Save codes

well first you take any variables that you would need EX) health, playerX, playerY, number of consumables left and simply join them:
setsave codetojoinjoinjoinjoinplayerx|playery|healthOutput would look something like 200|-50|79
then give them the code:
deleteallofcopy this!addsavecodetocopy this!showlistcopy this!
then to use this save code, do something like:
whenIreceiveask for save codeaskgimmie codeandwaitdeleteallofseparatedsetito1setsplittorepeatlengthofanswerif|=letteriofanswerthenaddsplittolistsetsplittoelsesetsplittojoinsplitletteriofanswerchangeiby1

Powered by DjangoBB