Discuss Scratch

icszacharytsang
Scratcher
4 posts

Permanent Achievements

Hi Scratchers!
I would like to create a project using permanent achievements under your username.
1. Is this disallowed/frowned upon?
2. If not, how do I code it?
Sincherelt, icszacharytsang
-Snipet-
Scratcher
500+ posts

Permanent Achievements

This is allowed, but very difficult. Could variables can only hold 128 numbers, so you could probably hold about 5 usernames per variable. The cloud is also relatively slow, so there is no guarantee the data would be saved. However, I have seen griffpatch do it before, so it’s possible.
deck26
Scratcher
1000+ posts

Permanent Achievements

Look at the wiki page on Global High Scores.

You have to use cloud variables for this but these only hold numeric data so you have to encode usernames (eg 01 for A, 02 for B etc) which generally means a username's length doubled tells you the minimum number of digits you'd need. You only have 10 cloud vars per project and each can only hold 256 digits so the amount you can store is limited.
icszacharytsang
Scratcher
4 posts

Permanent Achievements

Thank you for your advice, given an average username length of 16 I might be able to store 10 variables…?
Using deck26's character encoding (kudos) and the 16 achievements I'm storing in binary - 1 being collected -, each username would take 48 digits. Assuming cloud variables can store 256 digits, each can store 5 usernames, meaning 50 maximum usernames.
Is there a way to further improve this?
p.s. If each cloud variables can store 128 digits, i can store 20 usernames

Last edited by icszacharytsang (March 14, 2019 14:28:33)

deck26
Scratcher
1000+ posts

Permanent Achievements

icszacharytsang wrote:

Thank you for your advice, given an average username length of 16 I might be able to store 10 variables…?
Using deck26's character encoding (kudos) and the 16 achievements I'm storing in binary - 1 being collected -, each username would take 48 digits. Assuming cloud variables can store 256 digits, each can store 5 usernames, meaning 50 maximum usernames.
Is there a way to further improve this?
p.s. If each cloud variables can store 128 digits, i can store 20 usernames
128 digits was the limit in Scratch 2 before the update but 256 is current limit.

If you're using binary for the ‘achievements’ you can store 16 values in a data range from 0 to 2^16-1 which is 65535 so 5 digits would be enough for that. (Or store 2 or 3 achievements in a single digit and use 6 to 8 digits total.) But you either need to assume a fixed length of usernames or include a separator like 00. You should be able to save 5 usernames plus data in each cloud variable whichever option you choose.

It would be hard to improve that by much. You could treat the 10 variables as if they were one long string so you're looking at a data string of 2560 digits and don't have to worry where the breaks appear. To get 60 usernames you need to squeeze each user's data into an average of 42 digits.

In theory you can squeeze things tighter because you don't need 99 codes for the different charactes but you need around half that which (I think!) means you can store 4 characters in 7 digits instead of 8 but it gives you a lot of extra work.
cannonball84
Scratcher
58 posts

Permanent Achievements

another way is to store achievements offline. as in giving the user a string (ideally long and consists of most ASCII characters to stop forgery) that they copy&paste into their computer. there strings should also be encrypted with the user's username to make shared codes useless. this means a lot of work but infinite storage
deck26
Scratcher
1000+ posts

Permanent Achievements

cannonball84 wrote:

another way is to store achievements offline. as in giving the user a string (ideally long and consists of most ASCII characters to stop forgery) that they copy&paste into their computer. there strings should also be encrypted with the user's username to make shared codes useless. this means a lot of work but infinite storage
But also means you can't pregvent cheating without a lot of work if that matters.

Powered by DjangoBB