Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to save data for my Piano Tiles game?
- Scratch739201
-
Scratcher
500+ posts
How to save data for my Piano Tiles game?
How can I save data for my Piano Tiles game? For example, a person has 8 diamonds, 420 coins, 12 lives, these and that songs unlocked, etc…?
I only need to do that for 25-28 people (only that group plays my game, I have my game on another page), that means I could ask them what password they want to use, and every time they play my game, the password will save all the data (level, coins, lives, diamonds, unlocked songs, etc.)
That means, 25-28 passwords, they enter their password before they start to play, and it'll automatically save.
Is there a safe way how do that? I don't want the people to start at the very beginning every time they open my game.
I only need to do that for 25-28 people (only that group plays my game, I have my game on another page), that means I could ask them what password they want to use, and every time they play my game, the password will save all the data (level, coins, lives, diamonds, unlocked songs, etc.)
That means, 25-28 passwords, they enter their password before they start to play, and it'll automatically save.
Is there a safe way how do that? I don't want the people to start at the very beginning every time they open my game.
- yzscratcher
-
Scratcher
100+ posts
How to save data for my Piano Tiles game?
What should the game save?
The coins diamonds…
The coins diamonds…
- Scratch739201
-
Scratcher
500+ posts
How to save data for my Piano Tiles game?
That's not so difficultHow you do that?
E.g. my password is: abc123
I open my game, it asks me: “Password?”, then I enter “abc123” and it gives me back all my points I got: number of diamonds, coins, lives, and level, all the songs I unlocked (it has more than 50 songs!), what gift-card-codes I entered already, etc., etc….
- Scratch739201
-
Scratcher
500+ posts
How to save data for my Piano Tiles game?
What should the game save?Around 10 different things, plus a few of those the gift-card-codes I entered already, that means he should also save codes, like: a45b20-e309c1
The coins diamonds…
- deck26
-
Scratcher
1000+ posts
How to save data for my Piano Tiles game?
If you have a limited group you can avoid the need for encoding and decoding text if you also avoid using passwords. The Scratch username should be enough to idnentify the user so I wouldn't worry about passwords - or you could stick to a numeric code.
So you have the option of specifying a list of users and matching the current user with their item number in the list to give you an ID for the user. You can then store numeric data for each user in one or more cloud variables.
If you can use fixed length data it's easier but if not you can still use a separator. So for example the information for user 5 could be
05 - user id
08 - 8 diamonds (max 99)
0420 - 420 coins (max 9999)
12 - lives (max 99
050 - song 50 unlocked
101 - song 101 unlocked
005 - song 5 unlocked
000 - end of data
so that becomes 05080420050101005000 and can be joined to data from other users because the 000 acts as a separator.
So you have the option of specifying a list of users and matching the current user with their item number in the list to give you an ID for the user. You can then store numeric data for each user in one or more cloud variables.
If you can use fixed length data it's easier but if not you can still use a separator. So for example the information for user 5 could be
05 - user id
08 - 8 diamonds (max 99)
0420 - 420 coins (max 9999)
12 - lives (max 99
050 - song 50 unlocked
101 - song 101 unlocked
005 - song 5 unlocked
000 - end of data
so that becomes 05080420050101005000 and can be joined to data from other users because the 000 acts as a separator.
- yzscratcher
-
Scratcher
100+ posts
How to save data for my Piano Tiles game?
Ok, first you need two blocks:

Translate () to text::custom-argThat you can get in my Text <-> Number converter
Translate [] to number::custom-arg

Last edited by yzscratcher (Dec. 16, 2016 15:34:26)
- Scratch739201
-
Scratcher
500+ posts
How to save data for my Piano Tiles game?
But…how can I do that? If the cloud variables only allowed numbers, I cannot save the whole alphabet plus numbers from 1 to 9! And, how should the game find out what those numbers mean? It sounds so very complicated for me, I never worked with cloud. 

- deck26
-
Scratcher
1000+ posts
How to save data for my Piano Tiles game?
But…how can I do that? If the cloud variables only allowed numbers, I cannot save the whole alphabet plus numbers from 1 to 9! And, how should the game find out what those numbers mean? It sounds so very complicated for me, I never worked with cloud.Which is why I suggested working without needing to save text.
- yzscratcher
-
Scratcher
100+ posts
How to save data for my Piano Tiles game?
He means with the password StringBut…how can I do that? If the cloud variables only allowed numbers, I cannot save the whole alphabet plus numbers from 1 to 9! And, how should the game find out what those numbers mean? It sounds so very complicated for me, I never worked with cloud.Which is why I suggested working without needing to save text.
- deck26
-
Scratcher
1000+ posts
How to save data for my Piano Tiles game?
Which I also covered - no need for a password if you identify the user via their Scratch username.He means with the password StringBut…how can I do that? If the cloud variables only allowed numbers, I cannot save the whole alphabet plus numbers from 1 to 9! And, how should the game find out what those numbers mean? It sounds so very complicated for me, I never worked with cloud.Which is why I suggested working without needing to save text.
- yzscratcher
-
Scratcher
100+ posts
How to save data for my Piano Tiles game?
Yeah but the username is a string too and you can't save it in a cloud variable and you must convert it in a number. (Link above)Which I also covered - no need for a password if you identify the user via their Scratch username.He means with the password StringBut…how can I do that? If the cloud variables only allowed numbers, I cannot save the whole alphabet plus numbers from 1 to 9! And, how should the game find out what those numbers mean? It sounds so very complicated for me, I never worked with cloud.Which is why I suggested working without needing to save text.
- deck26
-
Scratcher
1000+ posts
How to save data for my Piano Tiles game?
My impression was they were working with a limited group of known usernames. If those are stored in the project you never need to store them in the cloud, just use the list as a reference. Again, that was in my original post.Yeah but the username is a string too and you can't save it in a cloud variable and you must convert it in a number. (Link above)Which I also covered - no need for a password if you identify the user via their Scratch username.He means with the password StringBut…how can I do that? If the cloud variables only allowed numbers, I cannot save the whole alphabet plus numbers from 1 to 9! And, how should the game find out what those numbers mean? It sounds so very complicated for me, I never worked with cloud.Which is why I suggested working without needing to save text.
- yzscratcher
-
Scratcher
100+ posts
How to save data for my Piano Tiles game?
Yeah, you can do this, but I would like it more when there all users could play and save. That would be nicer.My impression was they were working with a limited group of known usernames. If those are stored in the project you never need to store them in the cloud, just use the list as a reference. Again, that was in my original post.Yeah but the username is a string too and you can't save it in a cloud variable and you must convert it in a number. (Link above)Which I also covered - no need for a password if you identify the user via their Scratch username.He means with the password StringBut…how can I do that? If the cloud variables only allowed numbers, I cannot save the whole alphabet plus numbers from 1 to 9! And, how should the game find out what those numbers mean? It sounds so very complicated for me, I never worked with cloud.Which is why I suggested working without needing to save text.
- deck26
-
Scratcher
1000+ posts
How to save data for my Piano Tiles game?
Yeah, you can do this, but I would like it more when there all users could play and save. That would be nicer.Nevertheless, I answered the original poster of this topic and their particular requirement which is the point here!
It's always possible to do more than the current project requires so the code produced is more generally useful and it is always worth considering the options but my suggestion does give the easiest way forward except for the ‘gift-codes’ which were only mentioned later. However I don't understand how the OP wants them to work or why saving them is necessary. Such a system will be hard to do if you have any concerns about anyone reading the cloud data and cheating - anyone can read the cloud data by opening the project, just can't save except what the project allows them to save.
- Scratch739201
-
Scratcher
500+ posts
How to save data for my Piano Tiles game?
deck26, yzscratcher, they don't have a username. The group who is playing my game don't have any Scratch accounts, plus they are children who never worked with Scratch. Enter a password and yo get all the data back.
Last edited by Scratch739201 (Dec. 16, 2016 15:55:37)
- Scratch739201
-
Scratcher
500+ posts
How to save data for my Piano Tiles game?
@yzscratcher I have no idea how your text to code/code to text converter works! I think it's impossible to convert text to a number code, I'm sure. But if not, it's much too complex for me. You are the best programmer in your age in Germany, I think. You can get world famous or even a billionaire for having an extreme human brain. I think your brain is almost working like a computer 





























































- yzscratcher
-
Scratcher
100+ posts
How to save data for my Piano Tiles game?
I'm able to make it so that you can write a password in the project and your score will be saved.
- yzscratcher
-
Scratcher
100+ posts
How to save data for my Piano Tiles game?
Ok, the code isn't complex e.g. 010203 is the 01, the 02 and the 03 place in my letter list
- Discussion Forums
- » Help with Scripts
-
» How to save data for my Piano Tiles game?