Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
- Le_Koala
-
51 posts
How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
Hello,
I recently tested something on my alt account. I tried to create a system so that anybody can encode data in my project. I know you can't do it directly with the lists so I made a really simple coding that encrypt any sentence into a series of number (as a cloud variable) and then decrypt it to encode it into a list.
This part of the code works perfectly. The sentence is encrypted into a cloud variable with numbers and then decrypted and added into a list. The cloud variables are effectively working, even when I'm using another account, I checked it with “See data”.
But then I don't understand. The list do not save the new sentence added to it if I use a different account than the one I created the project with (“Le_Koala-Testing”).. while I thought it should because I added it using a cloud variable.
And if it's not possible to do that, then how do some scratchers succeed in creating games where the names of players are displayed with the best scores for example? Or social networks where random scratchers can write anything they want and it's saved?
The link of my project (it's shared): https://scratch.mit.edu/projects/398499471/
I recently tested something on my alt account. I tried to create a system so that anybody can encode data in my project. I know you can't do it directly with the lists so I made a really simple coding that encrypt any sentence into a series of number (as a cloud variable) and then decrypt it to encode it into a list.
This part of the code works perfectly. The sentence is encrypted into a cloud variable with numbers and then decrypted and added into a list. The cloud variables are effectively working, even when I'm using another account, I checked it with “See data”.
But then I don't understand. The list do not save the new sentence added to it if I use a different account than the one I created the project with (“Le_Koala-Testing”).. while I thought it should because I added it using a cloud variable.
And if it's not possible to do that, then how do some scratchers succeed in creating games where the names of players are displayed with the best scores for example? Or social networks where random scratchers can write anything they want and it's saved?
The link of my project (it's shared): https://scratch.mit.edu/projects/398499471/
Last edited by Le_Koala (May 24, 2020 20:48:13)
- codentag
-
100+ posts
How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
Scratch Wiki: https://en.scratch-wiki.info/wiki/Cloud_Data
This may be the problem. Even though entries are saved in “See data”, the variable won't update in game.
Also, you should be careful as this kind of project may count as a cloud chatroom. Cloud “social networks” have also since been forbidden.
If a variable is being updated too often, the cloud data server will drop the connection temporarily and updates will not be sent to the cloud data servers until the connection is automatically re-opened after a variable waiting period.
This may be the problem. Even though entries are saved in “See data”, the variable won't update in game.
Also, you should be careful as this kind of project may count as a cloud chatroom. Cloud “social networks” have also since been forbidden.
- Le_Koala
-
51 posts
How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
@codentag Thank you for your informations! I'm not trying to make a social network though, I'm recreating Akinator on Scratch and this coding is to insert more questions inside the game. What I just did is a project testing the system. It will only happen sometimes, I don't think that's forbidden.
However I don't really understand why my variable would be updated too often, because it's literally updated 1 time only. And how could I solve this issue? Making it in a way that it “waits” the cloud variable to be sent from the servers?
However I don't really understand why my variable would be updated too often, because it's literally updated 1 time only. And how could I solve this issue? Making it in a way that it “waits” the cloud variable to be sent from the servers?
- codentag
-
100+ posts
How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
Ah, I see the problem.
In your encrypt block, you're repeatedly setting the cloud variable for each iteration. This is most likely causing all the updates.
To fix this, I recommend doing this iteration in a normal variable, then after it's done, store it to the cloud variable. After an hour or so your cloud variables should work again.
In your encrypt block, you're repeatedly setting the cloud variable for each iteration. This is most likely causing all the updates.
To fix this, I recommend doing this iteration in a normal variable, then after it's done, store it to the cloud variable. After an hour or so your cloud variables should work again.
- deck26
-
1000+ posts
How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
Your encrypt custom block is writing directly to the cloud variable in a loop so it is writing too often to the cloud. You need to build a copy of the variable and only copy to the cloud variable when it is complete.
- Le_Koala
-
51 posts
How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
I edited my project and did what you said more than 12 hours ago. Is it normal that it still doesn't work?
I saw tutorials on YouTube, where people used a system similar to mine and for them it works without any problem.
Edit: I just recreated all the blocks and I checked the setting “Run without refresh” while creating them. Doesn't seem to work either.
I saw tutorials on YouTube, where people used a system similar to mine and for them it works without any problem.
Edit: I just recreated all the blocks and I checked the setting “Run without refresh” while creating them. Doesn't seem to work either.
Last edited by Le_Koala (May 25, 2020 11:55:45)
- deck26
-
1000+ posts
How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
Seems to work for me but this is too close to a chat project and those are not allowed. You have no control over what people can ‘say’ in your project.
When encoding rather than having a 0 between codes it would be better to just make everything a 2-digit code and add a leading zero for any codes that would be single digit. Your average code is currently 3 characters including the separator so you're wasting one third of very limited cloud space.
When encoding rather than having a 0 between codes it would be better to just make everything a 2-digit code and add a leading zero for any codes that would be single digit. Your average code is currently 3 characters including the separator so you're wasting one third of very limited cloud space.
- Le_Koala
-
51 posts
How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
It doesn't work because it's not saved inside the list. :-/
It's only saved when your computer is still running my project, but the list doesn't keep what you said.
And again, for the test I made a kind of “chatroom” but I dont want to make a chatroom. It's for people to enter a word that Akinator didn't guess. Then I'll moderate and add it to the game or not. It's not a chatroom. The process is similar but it's not. The list won't be displaid on the screen and even the code it won't be displaid like that. I could even encrypt it so nobody can read what's inside except another algorithm using another decoding list.
The main algorithm will only be used occasionally and have to be accurate. I don't want to be limited with 100 characters so I prefer to encode a 0 between codes :-) People aren't going to enter something longer than a sentence, it's not relevant in my project.
But for now it's not working.
It's only saved when your computer is still running my project, but the list doesn't keep what you said.
And again, for the test I made a kind of “chatroom” but I dont want to make a chatroom. It's for people to enter a word that Akinator didn't guess. Then I'll moderate and add it to the game or not. It's not a chatroom. The process is similar but it's not. The list won't be displaid on the screen and even the code it won't be displaid like that. I could even encrypt it so nobody can read what's inside except another algorithm using another decoding list.
The main algorithm will only be used occasionally and have to be accurate. I don't want to be limited with 100 characters so I prefer to encode a 0 between codes :-) People aren't going to enter something longer than a sentence, it's not relevant in my project.
But for now it's not working.
- deck26
-
1000+ posts
How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
Not sure how you expect the data to be saved to the list though. Your project can only get any data I add via cloud variables - me decoding to a list is not going to be seen by anyone else. Either data needs to be kept within the cloud variable rather than overwritten or you need a ‘server’ version of the project running all the time looking for new data. Even that would need to be saving the project regularly to keep any new data.
- Le_Koala
-
51 posts
How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
Is there a way to do that? Some scratchers manage to create games where the scores of players are saved for exemple, or chatrooms (I know chatrooms are forbideen but I'm defintely not making a chatroom, it's only for the test). So it's possible.
- deck26
-
1000+ posts
How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
Saving a score for a user is a case of storing the encoded username and their score in cloud variables. Multiple users may be stored in one cloud variable. the wiki page on Global High Scores is a good starting point. Anything like a chatroom probably only saved quite a lmited log of what had been said and again possibly by storing the username and encoded text (storing the item number for the word/phrase in a list takes less space than actually encoding the data).
So if user A's name is encoded as 12131415 and 00 is used as a separator you might store 1213141500123400 might represent the username and their score. If user B's equivalent is 34333200321400 you'd join those two together and you'd need a script which could decode these back to the original data.
But cloud variables are limited to 256 digits and you only have 10 per project.
So if user A's name is encoded as 12131415 and 00 is used as a separator you might store 1213141500123400 might represent the username and their score. If user B's equivalent is 34333200321400 you'd join those two together and you'd need a script which could decode these back to the original data.
But cloud variables are limited to 256 digits and you only have 10 per project.
- Le_Koala
-
51 posts
How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
And if I just want people to save the word/question they suggest into a list?
- deck26
-
1000+ posts
How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
You'd need to add that to the existing cloud data assuming it is not replacing something. If the username isn't required you just need to append the new encoded data to an existing cloud variable. And if I just want people to save the word/question they suggest into a list?
The only way that new data will becomd a permanent part of a list within the project is if you save it to a list while editing the project and make sure it is saved.
- secretagent123
-
1000+ posts
How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
Could you please put a link to the videos please. I edited my project and did what you said more than 12 hours ago. Is it normal that it still doesn't work?
I saw tutorials on YouTube, where people used a system similar to mine and for them it works without any problem.
Edit: I just recreated all the blocks and I checked the setting “Run without refresh” while creating them. Doesn't seem to work either.
- Le_Koala
-
51 posts
How should I do so that an user can encode data in my project? [CLOUD VARIABLES]
Nevermind, I found a way to do what I wanted to do a while ago. A system in multiple scripts that encode data in 10 cloud variables and is able to redecode them.
- Discussion Forums
- » Help with Scripts
-
» How should I do so that an user can encode data in my project? [CLOUD VARIABLES]