Discuss Scratch

gpc78
Scratcher
10 posts

Save Codes - How???

How do you make a save code so that they can keep their stuff when they exit the game???
zachs23
Scratcher
100+ posts

Save Codes - How???

Well, you can make an engine that generates a code, but every letter in the code “stands for” if they did a part of the game. Its hard to explain in words.

Example: https://scratch.mit.edu/projects/182816164/

☆Zach☆16☆Game developer☆Animator☆He/him☆An Ordinary Adventure creator☆

deck26
Scratcher
1000+ posts

Save Codes - How???

You need to decide what needs saving and how to encode it. For example a digit for lives, two for the level (leading zero if necessary) and so on. You know your game so you should know what needs saving. There's no right and wrong way of doing it as long as you include everything you want to save and can convert the code back to the data you want unambiguously.
gpc78
Scratcher
10 posts

Save Codes - How???

deck26 wrote:

You need to decide what needs saving and how to encode it. For example a digit for lives, two for the level (leading zero if necessary) and so on. You know your game so you should know what needs saving. There's no right and wrong way of doing it as long as you include everything you want to save and can convert the code back to the data you want unambiguously.
Okay, so what code would I use for that?
asivi
Scratcher
1000+ posts

Save Codes - How???

gpc78 wrote:

deck26 wrote:

You need to decide what needs saving and how to encode it. For example a digit for lives, two for the level (leading zero if necessary) and so on. You know your game so you should know what needs saving. There's no right and wrong way of doing it as long as you include everything you want to save and can convert the code back to the data you want unambiguously.
Okay, so what code would I use for that?

You go to https://scratch.mit.edu/projects/182816164/ by @zachs23 and have a look inside Sprite11 and Sprite12.
FuturePr0
Scratcher
100+ posts

Save Codes - How???

gpc78 wrote:

How do you make a save code so that they can keep their stuff when they exit the game???
What you can do according to what i understand about this post so far is put the code in your backpack.

BRUH
-Activation-
Scratcher
2 posts

Save Codes - How???

You could give them a number and when they input the save code you could use the number for the variable. Tell me if it doesnt make sense
HurculesAnimator
Scratcher
21 posts

Save Codes - How???

put the code in your backpack.
gtoal
Scratcher
1000+ posts

Save Codes - How???

gpc78 wrote:

How do you make a save code so that they can keep their stuff when they exit the game???
1) save the state in cloud variables
2) encode the state in a string and tell the user to enter the string next time they play


1 relies on the user having Scratcher status.

2 has problems. Doesn't matter if the data that is saved is a simple number eg a level, or a set of complex data (which can get big) - either way unless you are careful, one user can enter another user's string and skip ahead to that user's level. So you need to have a checksum and some way of encoding the username.

Tell us what kind of game you're writing and what data exactly you need to save and restore when you give the user a save code.

G

Last edited by gtoal (Dec. 5, 2017 03:07:43)

captainsilvergamer
Scratcher
9 posts

Save Codes - How???

when green flag clicked
forever
wait (0.1) secs
change [score v] by (1)
end
when green flag clicked
forever
if <key [s v] pressed?> then
add (score) to [save codes v]

end
end
when green flag clicked
forever
if <key [l v] pressed?> then
ask [code?] and wait
if <[save codes v] contains (answer) ?> then
say [it is found] for (2) secs



else
say [it is not found] for (2) secs

end
end
took me 30 mits to write

Last edited by captainsilvergamer (March 6, 2021 01:50:11)

TheReal_BestGamer
Scratcher
33 posts

Save Codes - How???

The most simple way I know is a method I call watering it down, basically you can't just string together a bunch of 0-10 values, because the computer needs to be able to read the code if you just said 1010 the computer could interpret that as 1 0 10, 10 10, 10 1 0, or 1 0 1 0 basically what you need to do is get the length of the lowest values to match the length of the highest values and the easiest way to do that is to add and subtract. So if you wanted a code for 1, 0, 10 you simply add 10 to each value making it 11, 10, 20 then the computer subtracts 10 when reading it.
TheReal_BestGamer
Scratcher
33 posts

Save Codes - How???

gtoal wrote:

gpc78 wrote:

How do you make a save code so that they can keep their stuff when they exit the game???
1) save the state in cloud variables
2) encode the state in a string and tell the user to enter the string next time they play


1 relies on the user having Scratcher status.

2 has problems. Doesn't matter if the data that is saved is a simple number eg a level, or a set of complex data (which can get big) - either way unless you are careful, one user can enter another user's string and skip ahead to that user's level. So you need to have a checksum and some way of encoding the username.

Tell us what kind of game you're writing and what data exactly you need to save and restore when you give the user a save code.

G

Actually, if you encode the username, a talented coder could simply figure out how to edit the username to their own. So, you probably just shouldn't worry about someone cheating to get ahead as someone could cheat it anyway.
Harakou
Scratcher
1000+ posts

Save Codes - How???

Hi! Thank you for offering your help, but this thread is pretty old - I don't think it's relevant anymore. When you respond to a topic, please make sure it's recent and the original poster still needs an answer. Thanks!

Powered by DjangoBB