Discuss Scratch

Ghxstify2009
Scratcher
100+ posts

Online Cloud Variable

How do I create an online library full of usernames and corresponding ‘ranks’? I want to do this so that I can keep track of my members and associate a rank with their username, so that when they enter their username in a rank tracker project they will be able to see their rank
Ghxstify2009
Scratcher
100+ posts

Online Cloud Variable

bump
caftingdead261
Scratcher
100+ posts

Online Cloud Variable

you can use scratch attach
BigNate469
Scratcher
1000+ posts

Online Cloud Variable

caftingdead261 wrote:

you can use scratch attach
Nothing in the OP's question actually requires the Scratch API, and thus does not require scratchattach.
Just create a program with one list (if in Scratch)/array (if anywhere else) that has a list of usernames that have a rank. Then, have another with their rank (if in Scratch), or (if anywhere else) create an object/dictionary inside each array item that holds the user's name and rank.
Note: you will have to update rank manually, because Scratch* doesn't provide a way to do this, because you can't rank people from inside Scratch (outside of the three levels of New Scratcher, Scratcher, and Scratch Team, which are applied already anyways)

*using anything the ST has built into Scratch, anyways.

Last edited by BigNate469 (May 2, 2024 19:51:35)

CST1229
Scratcher
1000+ posts

Online Cloud Variable

BigNate469 wrote:

(#4)
Nothing in the OP's question actually requires the Scratch API, and thus does not require scratchattach.
Just create a program with one list (if in Scratch)/array (if anywhere else) that has a list of usernames that have a rank. Then, have another with their rank (if in Scratch), or (if anywhere else) create an object/dictionary inside each array item that holds the user's name and rank.
Note: you will have to update rank manually, because Scratch* doesn't provide a way to do this, because you can't rank people from inside Scratch (outside of the three levels of New Scratcher, Scratcher, and Scratch Team, which are applied already anyways)

*using anything the ST has built into Scratch, anyways.
Cloud lists don't exist though, so you have to encode the list into numbers and use a cloud variable.
Stegie1234
Scratcher
100+ posts

Online Cloud Variable

BigNate469 wrote:

caftingdead261 wrote:

you can use scratch attach
Nothing in the OP's question actually requires the Scratch API, and thus does not require scratchattach.
[…]
Cloud variables cannot store enough data and updating local variables or lists manually would be impractical. This would mean using an external database to store the map, and would require scratchattach or a similar API to transfer data between the database and the Scratch project.

Last edited by Stegie1234 (May 3, 2024 10:26:13)

Ghxstify2009
Scratcher
100+ posts

Online Cloud Variable

Cloud variables sadly don't accept letters, so it's kinda difficult to create that.
ninjaMAR
Scratcher
1000+ posts

Online Cloud Variable

Ghxstify2009 wrote:

(#7)
Cloud variables sadly don't accept letters, so it's kinda difficult to create that.
Use a cloud list, then implement a key value store
Ghxstify2009
Scratcher
100+ posts

Online Cloud Variable

What do you mean by cloud list? I know Scratch doesn't yet have a ‘cloud’ list feature available, but there may be a way to create one.. could you provide a link to a tutorial/project/etc.?
qloakonscratch
Scratcher
1000+ posts

Online Cloud Variable

Ghxstify2009 wrote:

What do you mean by cloud list? I know Scratch doesn't yet have a ‘cloud’ list feature available, but there may be a way to create one.. could you provide a link to a tutorial/project/etc.?
A relatively modern and easy-to-follow tutorial can be found here: https://scratch.mit.edu/projects/493258809/

You can also look up “Cloud List” in the search bar and check there to see if there's anything that can help you.
ninjaMAR
Scratcher
1000+ posts

Online Cloud Variable

Ghxstify2009 wrote:

(#9)
What do you mean by cloud list? I know Scratch doesn't yet have a ‘cloud’ list feature available, but there may be a way to create one.. could you provide a link to a tutorial/project/etc.?
https://scratch.mit.edu/projects/495545839/
LIZARD_OFFICIAL
Scratcher
100+ posts

Online Cloud Variable

EasyDB is great for that!
ninjaMAR
Scratcher
1000+ posts

Online Cloud Variable

LIZARD_OFFICIAL wrote:

(#12)
EasyDB is great for that!
That seems a little overkill. Normal cloud list implementations should work just fine
ninjaMAR
Scratcher
1000+ posts

Online Cloud Variable

Stegie1234 wrote:

(#6)

BigNate469 wrote:

caftingdead261 wrote:

you can use scratch attach
Nothing in the OP's question actually requires the Scratch API, and thus does not require scratchattach.
[…]
Cloud variables cannot store enough data and updating local variables or lists manually would be impractical. This would mean using an external database to store the map, and would require scratchattach or a similar API to transfer data between the database and the Scratch project.
You can store 2560 characters in cloud variables (10 cloud variables * 256 characters)
davidtheplatform
Scratcher
500+ posts

Online Cloud Variable

ninjaMAR wrote:

Stegie1234 wrote:

(#6)

BigNate469 wrote:

caftingdead261 wrote:

you can use scratch attach
Nothing in the OP's question actually requires the Scratch API, and thus does not require scratchattach.
[…]
Cloud variables cannot store enough data and updating local variables or lists manually would be impractical. This would mean using an external database to store the map, and would require scratchattach or a similar API to transfer data between the database and the Scratch project.
You can store 2560 characters in cloud variables (10 cloud variables * 256 characters)
Cloud vars can only hold digits, not letters so you get 2560 digits. This works out to about a kilobyte of data. If we assume 2x compression on usernames*, an average of 8 characters per username, and 2 bytes of extra data per entry, we can store ~166 total entries.
If you just want a leaderboard this will work, but if you want actual cloud saving you'd need to use a server to handle things.

p.s. The theoretical throughput of cloud variables is 10kb/sec, but I've found that only around half that is possible.
ninjaMAR
Scratcher
1000+ posts

Online Cloud Variable

davidtheplatform wrote:

Cloud vars can only hold digits, not letters so you get 2560 digits. This works out to about a kilobyte of data. If we assume 2x compression on usernames*, an average of 8 characters per username, and 2 bytes of extra data per entry, we can store ~166 total entries.
If you just want a leaderboard this will work, but if you want actual cloud saving you'd need to use a server to handle things.

p.s. The theoretical throughput of cloud variables is 10kb/sec, but I've found that only around half that is possible
what do you mean by 2x compression? (typo?) my understanding is that you need 2 digits per character of the alphabet, meaning that a username needs 2x space
davidtheplatform
Scratcher
500+ posts

Online Cloud Variable

ninjaMAR wrote:

davidtheplatform wrote:

Cloud vars can only hold digits, not letters so you get 2560 digits. This works out to about a kilobyte of data. If we assume 2x compression on usernames*, an average of 8 characters per username, and 2 bytes of extra data per entry, we can store ~166 total entries.
If you just want a leaderboard this will work, but if you want actual cloud saving you'd need to use a server to handle things.

p.s. The theoretical throughput of cloud variables is 10kb/sec, but I've found that only around half that is possible
what do you mean by 2x compression? (typo?) my understanding is that you need 2 digits per character of the alphabet, meaning that a username needs 2x space
There's roughly 65 characters you can use in a username, so if we encode them properly we only need 1.8 digits per character. Some letters are more/less common, ie. “Q” is probably used less than “e”. We can use huffman coding (or something similar) to get a little bit more compression. Normal english text can be compressed by about 8x for reference.

Various other methods could be used, like truncating usernames to 5 characters, but then you'd have to deal with collisions.
ninjaMAR
Scratcher
1000+ posts

Online Cloud Variable

davidtheplatform wrote:

(#17)
There's roughly 65 characters you can use in a username, so if we encode them properly we only need 1.8 digits per character. Some letters are more/less common, ie. “Q” is probably used less than “e”. We can use huffman coding (or something similar) to get a little bit more compression. Normal english text can be compressed by about 8x for reference.

Various other methods could be used, like truncating usernames to 5 characters, but then you'd have to deal with collisions.
Interesting! Do you have a Proof-Of-Concept?

ninjaMAR wrote:

(#11)
https://scratch.mit.edu/projects/495545839/
I updated the project to include an API that you can use. Directions are in the editor.
davidtheplatform
Scratcher
500+ posts

Online Cloud Variable

ninjaMAR wrote:

davidtheplatform wrote:

(#17)
There's roughly 65 characters you can use in a username, so if we encode them properly we only need 1.8 digits per character. Some letters are more/less common, ie. “Q” is probably used less than “e”. We can use huffman coding (or something similar) to get a little bit more compression. Normal english text can be compressed by about 8x for reference.

Various other methods could be used, like truncating usernames to 5 characters, but then you'd have to deal with collisions.
Interesting! Do you have a Proof-Of-Concept?.
All of these numbers are based on a 10000 “random” usernames.
The 3 approaches I've tested so far are: 1 letter = 2 digits, 1 letter = ~1.8 digits (no compression, just packing the username efficiently), and using huffman coding. Also, there's an algorithm to calculate the entropy of the data, which is the lowest possible value no matter how the data is encoded.
Results:
base:     14.8 digits per username
packing: 13.4
huffman: 11.2
best: 11.1

Lossy encoding
I'll write this part in a few hours
Ghxstify2009
Scratcher
100+ posts

Online Cloud Variable

ninjaMAR wrote:

davidtheplatform wrote:

(#17)
There's roughly 65 characters you can use in a username, so if we encode them properly we only need 1.8 digits per character. Some letters are more/less common, ie. “Q” is probably used less than “e”. We can use huffman coding (or something similar) to get a little bit more compression. Normal english text can be compressed by about 8x for reference.

Various other methods could be used, like truncating usernames to 5 characters, but then you'd have to deal with collisions.
Interesting! Do you have a Proof-Of-Concept?

ninjaMAR wrote:

(#11)
https://scratch.mit.edu/projects/495545839/
I updated the project to include an API that you can use. Directions are in the editor.
I would also like to associate a rank with specific usernames though, and allow other people to see it.

Is there a way on Scratch like in Python to add onto the username such as: +“Rank = Bronze”

Last edited by Ghxstify2009 (May 7, 2024 14:59:56)

Powered by DjangoBB