Discuss Scratch
- stickfiguregames01
-
18 posts
Username Sensing?
Right now, I'm making an OS. I thought it would be cool if I could program the game to allow you to save your password on a cloud variable, so when you re-enter the code, your username is displayed onscreen. Does anyone know how I could link the variable to someone's username so that I don't need to program a million variables for every new user? (My goal is to be able to have people enter an 8-digit pass code, and then when they enter it into the system, the variable sets the username to the correct one based on the code. I'm trying to use only one or two variables, if possible.)
-discussion is closed: thanks for the help!
-discussion is closed: thanks for the help!

Last edited by stickfiguregames01 (Nov. 26, 2013 19:41:41)
- sonicfan12p
-
1000+ posts
Username Sensing?
You can use only one variable if you must, but it would be easier with two. I'll come back tomorrow with some scratchblocks for you, but right now my keyboard's messed up. 

- stickfiguregames01
-
18 posts
Username Sensing?
You can use only one variable if you must, but it would be easier with two. I'll come back tomorrow with some scratchblocks for you, but right now my keyboard's messed up.
Awesome, thanks a ton! This will make my OS way better!
- sonicfan12p
-
1000+ posts
Username Sensing?
Yes. Yes it will. Especially since most people think it's impossible, and don't want to try, so you'd likely be one of the first to have this feature. 
Anyway, I'll show you how to do it with two, if you need me to do just one, then I'll make the necessary changes.
First off, you'll need a way to translate the usernames to numbers.
That script will look something like this…
And so on and so forth, continuing that pattern till you have the entire alphabet. It is of utmost importance that you encode in two character numbers, so whatever you do, don't change that.
Now, we would have a variable, My Username, that for me would look like this. 112824231812151023010225
What the heck are we going to do with that? I'll show you.
Once you make it to the end of that script, AFTER the end of the repeat block, put these blocks.
This will add your encoded username to the cloud, and it will also attempt to ensure the cloud is stable before proceeding. It's not 100%, because cloud data is still a bit glitchy, but that will help some.
Now all of this info is on the cloud, but what does that help? Nothing if we don't know how to retranslate it. Before we can retranslate it though, it's sometimes better to decompress it into a list first. That would look like this.
That would be the decompressor. Not too horribly complicated when you really think about it, and it makes retranslating just that little bit easier.
The last custom block in saving these usernames would be the retranslator itself. Its structure is similar to the first script, with a few key differences.
Here's a look at it…
Then, at the end of the repeat block, similar to the first script, we have this script.
After this step, 112824231812151023010225 has turned back into sonicfan12p. You now have your username system, but what about passwords?
You mentioned you wanted the passwords to be in 8 digit codes, making this process relatively easy. The first thing we must do is make a password, this is the script for that.
You'll see what those broadcasts do, all in good time.
That script saves the password that was created to the cloud. But it doesn't let us use that info, does it? That's what this next script does.
Now the passwords save are all in manageable form, a list. Not only that, but the item number of each password corresponds to the item number of each username.
Now that we have all our custom blocks, it's time to put them into action. First, I'll remind you what they all are. Then, we'll see where they all go, to make this thing work.
This will check to see if you already have an account. If you don't, it will create one. If you do have an account, it will ask for your password. It already knows your username, so it checks to see if you put in your account's password.
This is perfectly secure, but there's one slight catch. Having this doesn't help you if you don't save the user's preferences and settings. This requires a third variable, but I'll wait and see what you want to do about that.
If you really want it, I'll show you how to do that too, but you'll need to tell me what about your O.S. can people change and/or save.
Hope you found this helpful, Scratch On!

Anyway, I'll show you how to do it with two, if you need me to do just one, then I'll make the necessary changes.
First off, you'll need a way to translate the usernames to numbers.
That script will look something like this…
And so on and so forth, continuing that pattern till you have the entire alphabet. It is of utmost importance that you encode in two character numbers, so whatever you do, don't change that.
Now, we would have a variable, My Username, that for me would look like this. 112824231812151023010225
What the heck are we going to do with that? I'll show you.
Once you make it to the end of that script, AFTER the end of the repeat block, put these blocks.
This will add your encoded username to the cloud, and it will also attempt to ensure the cloud is stable before proceeding. It's not 100%, because cloud data is still a bit glitchy, but that will help some.
Now all of this info is on the cloud, but what does that help? Nothing if we don't know how to retranslate it. Before we can retranslate it though, it's sometimes better to decompress it into a list first. That would look like this.
That would be the decompressor. Not too horribly complicated when you really think about it, and it makes retranslating just that little bit easier.
The last custom block in saving these usernames would be the retranslator itself. Its structure is similar to the first script, with a few key differences.
Here's a look at it…
Then, at the end of the repeat block, similar to the first script, we have this script.
After this step, 112824231812151023010225 has turned back into sonicfan12p. You now have your username system, but what about passwords?
You mentioned you wanted the passwords to be in 8 digit codes, making this process relatively easy. The first thing we must do is make a password, this is the script for that.
You'll see what those broadcasts do, all in good time.

That script saves the password that was created to the cloud. But it doesn't let us use that info, does it? That's what this next script does.
Now the passwords save are all in manageable form, a list. Not only that, but the item number of each password corresponds to the item number of each username.
Now that we have all our custom blocks, it's time to put them into action. First, I'll remind you what they all are. Then, we'll see where they all go, to make this thing work.
This will check to see if you already have an account. If you don't, it will create one. If you do have an account, it will ask for your password. It already knows your username, so it checks to see if you put in your account's password.
This is perfectly secure, but there's one slight catch. Having this doesn't help you if you don't save the user's preferences and settings. This requires a third variable, but I'll wait and see what you want to do about that.
If you really want it, I'll show you how to do that too, but you'll need to tell me what about your O.S. can people change and/or save.
Hope you found this helpful, Scratch On!

Last edited by sonicfan12p (Nov. 8, 2013 17:07:45)
- stickfiguregames01
-
18 posts
Username Sensing?
Thanks a ton! That helps me a lot! One more question: do you know if its possible to allow people to download their own music/projects/etc. into an O.S. made on Scratch? So far I haven't found a way to allow people to do that, but maybe you did?
- sonicfan12p
-
1000+ posts
Username Sensing?
Thanks a ton! That helps me a lot! One more question: do you know if its possible to allow people to download their own music/projects/etc. into an O.S. made on Scratch? So far I haven't found a way to allow people to do that, but maybe you did?
Well…it's not possible just from the project screen, but if one were to go into the editor they could do that. However, it wouldn't save unless they remixed your project.
There are a couple of things that one could download into the O.S. without going into the editor, and that would be raw information (notes, essays, ect.) and bit map art. This could be done by copying your code, and then pasting it back into the project when asked to import.
However, saving such things as art and text on the cloud can be very resource intensive, and very prone to corruption due to the large amount of numbers required to store that information.
Also, did you want it to save settings too?
Last edited by sonicfan12p (Nov. 8, 2013 22:56:58)
- stickfiguregames01
-
18 posts
Username Sensing?
Thanks a ton! That helps me a lot! One more question: do you know if its possible to allow people to download their own music/projects/etc. into an O.S. made on Scratch? So far I haven't found a way to allow people to do that, but maybe you did?
Well…it's not possible just from the project screen, but if one were to go into the editor they could do that. However, it wouldn't save unless they remixed your project.
There are a couple of things that one could download into the O.S. without going into the editor, and that would be raw information (notes, essays, ect.) and bit map art. This could be done by copying your code, and then pasting it back into the project when asked to import.
However, saving such things as art and text on the cloud can be very resource intensive, and very prone to corruption due to the large amount of numbers required to store that information.
Also, did you want it to save settings too?
Yes, I want to try to save settings like a customizable color scheme, and different apps.


- jkibbe
-
32 posts
Username Sensing?
At the bottom of http://scratch.mit.edu/discuss/ you can click on ‘change your signature’ if you want to add an image or text automatically to every forum post…
- stickfiguregames01
-
18 posts
Username Sensing?
http://scratch.mit.edu/discuss/ you can click on ‘change your signature’ if you want to add an image or text automatically to every forum post…At the bottom of
Ok, thanks!
Last edited by stickfiguregames01 (Nov. 25, 2013 19:58:30)
- lederniersamourai
-
500+ posts
Username Sensing?
One important remark:
you must tell the user not to introduce their scratch password.
This is required by the “ode of conduct” of Scratch.
Young users could do that and you would be able to steal their password.
There are a lot of discussions abou that.
you must tell the user not to introduce their scratch password.
This is required by the “ode of conduct” of Scratch.
Young users could do that and you would be able to steal their password.
There are a lot of discussions abou that.
- lederniersamourai
-
500+ posts
Username Sensing?
This is perfectly secure, but there's one slight catch. Having this doesn't help you if you don't save the user's preferences and settings. This requires a third variable, but I'll wait and see what you want to do about that.
Cloud vars are not secure. They are designed so that anyone can see their content and can decode it.
Even a new scratcher that is not allowed to create cloud vars can see what is inside cloud vars, or even can create a script to decode what is in a cloud var.
See this: http://scratch.mit.edu/projects/14712331/
Be careful with personal info of your users.
Last edited by lederniersamourai (Nov. 25, 2013 21:06:16)
- AonymousGuy
-
1000+ posts
Username Sensing?
*All the scripts sonicfan12p wrote*
Em, that encode process would make me go crazy.
Instead, use scripts that generate a list of all the chars and a second of all the ids and whenever you need to decode, you just look for the letter / num combo that you are trying to encode/decode and get its equivalent out of the other list.
Hope that helps reduce the lag while editing!
- stickfiguregames01
-
18 posts
Username Sensing?
One important remark:
you must tell the user not to introduce their scratch password.
This is required by the “ode of conduct” of Scratch.
Young users could do that and you would be able to steal their password.
There are a lot of discussions abou that.
Well, actually, I'm not asking for their real password, I'm just writing a script so you can make your own. It's basically just a code so that the OS remembers your color settings.. To make it more secure, now that you brought that up about people entering a real password, I could write a script so that you can *only* enter an 8 number password, so that no one accidently enters a real one.

- NoMod-Test
-
93 posts
Username Sensing?
*facepalm* don't necropost, please. Is there a quicker way possibly?
- Hungry_Kumquat
-
32 posts
Username Sensing?
In case you don't know, “necroposting” means posting on a topic that's quite old. Is there a quicker way possibly?
Please, make your own topic instead of necroposting next time, okay?

Also, what do you mean by “quicker”?
This script should run pretty fast unless you're having connection problems to the Scratch servers.
If you mean an “easier” way… - cloud lists are intentionally complicated so people don't make chatrooms.
- AwesomeManJesse
-
48 posts
Username Sensing?
Wow, this must be old. (sorry for necroposting)
However, this is really annoying me. Instead of doing that complicated encoding and decoding process,
just do this!
or
And I know, cloud variables probably didn't exist in 2013, but I don't care.
EDIT: Nevermind, the first one won't work. I tried it and apparently only numbers can be put onto cloud variables
I'm dumb. But, however, the second one definitely will work, especially if you do this instead:
However, this is really annoying me. Instead of doing that complicated encoding and decoding process,
just do this!
or
And I know, cloud variables probably didn't exist in 2013, but I don't care.

EDIT: Nevermind, the first one won't work. I tried it and apparently only numbers can be put onto cloud variables

Last edited by AwesomeManJesse (June 11, 2016 23:06:56)
- deck26
-
1000+ posts
Username Sensing?
Cloud variables cannot store text, only nemeric data. That's why encoding/decoding is required. Wow, this must be old. (sorry for necroposting)
However, this is really annoying me. Instead of doing that complicated encoding and decoding process,
just do this!
or
And I know, cloud variables probably didn't exist in 2013, but I don't care.
- AwesomeManJesse
-
48 posts
Username Sensing?
Well, I realised that right after posting it. Cloud variables cannot store text, only nemeric data. That's why encoding/decoding is required.

- deck26
-
1000+ posts
Username Sensing?
Apologies for the nemeric typo.Well, I realised that right after posting it. Cloud variables cannot store text, only nemeric data. That's why encoding/decoding is required.But, in the edit I just made, I made a better one. Also, numeric*
However adding usernames to a list has nothing to do with storing them in the cloud which is what this topic is about.