Discuss Scratch

Isabelle_Silverore
Scratcher
11 posts

How to make a Cloud Leaderboard

I need to make a cloud leaderboard for my game, but I can't figure it out. Can someone post the code here for a 10-person leaderboard?
nubynub
Scratcher
60 posts

How to make a Cloud Leaderboard

There are many ways to do so, but there are two or three main ways. If you go on youtube and look up “scratch leaderboard tutorial” then you will find some good tutorials on how to make one
Arctevious
Scratcher
500+ posts

How to make a Cloud Leaderboard

there are two problems you'll need to overcome…

1. cloud variable won't store letters/symbols (so you cant store the names of people)
2. lists don't save new information made by players only you.

these things are crucial when making a leader board.

to bypass the fact cloud variables don't store anything else but numbers…. is to use those numeric values to our advantage…

make 2 lists. one for letters, and one for 3 digit numbers… i recommend you use this chart to help fill in the lists: https://www.alpharithms.com/ascii-table-512119/

anyway now the fact that you can't save list is a problem… so we need to take these coded ID's of the names and revert them back to the origonal values and put them in the list 1 by 1 until you have a high score list every time the project is run.

my game snake has kind of the same idea, i recommend you remix it and tear everything down except the username list values, and put them in your backpack. https://scratch.mit.edu/projects/663461481/

Last edited by Arctevious (April 22, 2022 17:47:46)

dave3m
Scratcher
500+ posts

How to make a Cloud Leaderboard

To expand a little bit on what @Arctevious explained further above, the general idea will be to store (encode) all ten entries for your Cloud Leaderboard into a single variable.

There are different ways to do it, but the easiest may be to use a fixed size for each piece of data that you want to store.

E.g.,
Whose score is it?
- This will need to be encoded into the numerical digits stored in your Cloud variable, using a strategy to convert non-digit information into digits and back again
- If you are storing usernames and want to have fixed-length entries in your stored leaderboard data, you may need to truncate them somehow

What was their score?
- This value is already numerical, but you may wish to pad out the value to fixed width to make it easy to read back

When did they achieve this score?
- Dates can also be easily encoded as digits in your cloud variable. Again, be careful to pad out the numbers if that is your strategy, since the time sense blocks don't include the extra zeroes.
(current [year])
(current [month])
(current [date])

What other pertinent values do you need to remember?
- You may have other details to attribute to the score, such as the difficulty mode, how long they spent to achieve it, or what level they reached.


Once you have figured out all the data that you need to store for a single Leaderboard entry, and how you will encode it, you can join all the pieces together into one big long number that you can predictably unpack again. Having fixed widths for each data field makes it much easier when reading the information back, but there are other strategies as well.
(join [workingLeaderboard] [nextField])

Now you just need to put all of your multiple Leaderboard entries together!
You may wish to start your cloud variable by recording how many entries are in the stored leaderboard (thankfully, another number that can easily have a fixed width of say 2 digits). That way, when you read your Leaderboard back from the cloud variable, you will know how many times you need to read data from the string of digits to create entries to display in your Leaderboard (and how much to expect). Then join each block of data, representing a fully encoded Leaderboard entry, one after the other onto your single variable.

Your final Leaderboard variable ends up looking something like this (the parentheses just show different sections of data, but it's all digits):

( # entries ) ( entry 1 data ) ( entry 2 data ) . . . ( entry n data )


Finally,
It's a good idea to put all of this information together in a temporary working variable, before writing it to the actual Cloud variable. Scratch has limits on how often they want you to write to a Cloud variable, so it makes sense to do all of the joins / construction of your encoded Leaderboard first and then store it once as a single value to your actual Cloud Variable.

You will probably also have lists / variables in your project that store the information that makes up your Leaderboard. The form that these variables take will be what is most appropriate for your project, which facilitate you maintaining and displaying this information. Chances are you will have one or more lists that keep track of the different data fields that go with each Leaderboard entry. You might even have separate Leaderboard description strings that will show your user a pretty, formatted layout of each entry in the Leaderboard (which you might display to the user in either a list of formatted text or a series of individual variables).


The project featured in my profile uses the above approach (including an encoder to map characters to numerical values for attributing score entries to users, as suggested above by @Arctevious). The actual project is getting rather complex, however, so you may find smaller / dedicated examples easier to draw from. I'd be happy to explain where the pieces are.

Good luck and let us know how you are making out!

Last edited by dave3m (April 23, 2022 00:08:09)

AnUnkownScratcher
Scratcher
16 posts

How to make a Cloud Leaderboard

Arctevious wrote:

there are two problems you'll need to overcome…

1. cloud variable won't store letters/symbols (so you cant store the names of people)
2. lists don't save new information made by players only you.

these things are crucial when making a leader board.

to bypass the fact cloud variables don't store anything else but numbers…. is to use those numeric values to our advantage…

make 2 lists. one for letters, and one for 3 digit numbers… i recommend you use this chart to help fill in the lists: https://www.alpharithms.com/ascii-table-512119/

anyway now the fact that you can't save list is a problem… so we need to take these coded ID's of the names and revert them back to the origonal values and put them in the list 1 by 1 until you have a high score list every time the project is run.

my game snake has kind of the same idea, i recommend you remix it and tear everything down except the username list values, and put them in your backpack. https://scratch.mit.edu/projects/663461481/

I mean you could like make a list of usernames without cloud variables and then make another list to kinda make a code key and then make encrypt and decryption scripts and make it loop through all the usernames in the list and put it in the leaderboard list and always reset the leaderboard so it is live.
mpkea2022
Scratcher
2 posts

How to make a Cloud Leaderboard

Hi guys i made a flip a coin game can you help me get to 500 followers and get the project to 1k views 5 remixes and 12 likes and favs heres the link it took ages and if u have ideas tell me in the comments also pls help me make a cloud leaderboard with the top 50 ppl pls and ty heres the link now: https://scratch.mit.edu/projects/1214210037/
Shuaib_Zaker
Scratcher
98 posts

How to make a Cloud Leaderboard

mpkea2022 wrote:

Hi guys i made a flip a coin game can you help me get to 500 followers and get the project to 1k views 5 remixes and 12 likes and favs heres the link it took ages and if u have ideas tell me in the comments also pls help me make a cloud leaderboard with the top 50 ppl pls and ty heres the link now: https://scratch.mit.edu/projects/1214210037/
Don't Necropost (post on old resolved topics) put that in the show and tell fouroum.
AYSomkiv
Scratcher
5 posts

How to make a Cloud Leaderboard

If you want a 10 length cloud list, you can use the 10 cloud variables, and name them like, CLOUD 1 or CLOUD 2 to show what place it is, and when the user requests the leaderboard, use add to list (CLOUD 1), for decoding and encoding, well, the link you are going to get is the same technology that aysTab2 and aysTab3 (coming very soon!) uses, and is very compact, also you will need to add in the list values yourself, because they get deleted when you backpack: https://scratch.mit.edu/projects/1214600490/
mpkea2022
Scratcher
2 posts

How to make a Cloud Leaderboard

Shuaib_Zaker wrote:

mpkea2022 wrote:

Hi guys i made a flip a coin game can you help me get to 500 followers and get the project to 1k views 5 remixes and 12 likes and favs heres the link it took ages and if u have ideas tell me in the comments also pls help me make a cloud leaderboard with the top 50 ppl pls and ty heres the link now: https://scratch.mit.edu/projects/1214210037/
Don't Necropost (post on old resolved topics) put that in the show and tell fouroum.
_Macs
Scratcher
1 post

How to make a Cloud Leaderboard

Yall ´ this isn't helping me at all!
cubetube7
Scratcher
62 posts

How to make a Cloud Leaderboard

_Macs wrote:

Yall ´ this isn't helping me at all!

to make this more simple, i'm going to pretend this leaderboard only has one person on it (but this can be easily expanded)

let's say that you only have two values to store: a username and a score

firstly, we will have to turn each letter in the username to a 2-digit number. if we pretend that only letters can be in a username, then our code will have a letter list with every letter from a - z

define turn (username) into numbers
set [letter # v] to [1]
set [digits v] to []
repeat until <(letter #) > (length of (username))>
set [digits v] to (join (digits) (item # of (letter (letter #) of (username)) in [letter list v]))
change [letter # v] by (1)
end

now that we have a way to turn a username into numbers, we also need a way to seperate the usernames from the scores. this is easy, just add “99” to act as a seperator

so then the finished code would be:

ask [what score did you get] and wait
turn (username) into numbers::custom
set [☁ leaderboard v] to (join (digits) (join [99] (answer)))

and then you can repeat this for other usernames and scores and information, just remember to use “99” as a seperator

to get the information back from the cloud leaderboard variable, you just do this in reverse, where you read 2 digits at a time, turn them back into letters, and then make sure to switch between reading the score and reading the username when you encounter a “99”
dem_bot
Scratcher
500+ posts

How to make a Cloud Leaderboard

YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
cubetube7
Scratcher
62 posts

How to make a Cloud Leaderboard

dem_bot wrote:

YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
i forget to check when things are posted
Evilguy2428
Scratcher
1 post

How to make a Cloud Leaderboard

dem_bot wrote:

YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
YALL JUST STOP IT. THIS THING IS LIKE 5 YEARS OLD!!!
the reason is because it could help others in the future
idsdp
Scratcher
14 posts

How to make a Cloud Leaderboard

add  to [list v]
add [] to [list v]
add [] to [list v]
add [] to [list v]
add [] to [list v]
add [] to [list v]
add [] to [list v]
add [] to [list v]
add [] to [list v]
add [] to [list v]
add [] to [list v]
add [] to [list v]
add [] to [list v]
add [] to [list v]
add [] to [list v]
add [] to [list v]

Powered by DjangoBB