Discuss Scratch

epep_dragon
Scratcher
8 posts

Creating profiles

I'm creating a game, it requires the user to be able to create a undefined number of profiles through a GUI and save scores for them.
I cannot figure out how to do this with the features of scratch, please help.
deck26
Scratcher
1000+ posts

Creating profiles

If you want to save data for a particular Scratch user so next time they run the project that data will be available automatically you need to use cloud varaibles but you're shown as New to Scratch so can't currently use cloud variables. To become a Scratcher keep creating and sharing and generally taking part in things on Scratch.
epep_dragon
Scratcher
8 posts

Creating profiles

I believe you are misunderstanding the question.

The game is offline and self contained.
The profiles are not related to the profiles of the scratch website, so I need to code a system that the user can create a profile contained in the game.
That's what I can't seem to figure out.

Thanks for answer anyway.
deck26
Scratcher
1000+ posts

Creating profiles

So you need to decide what data you need for each profile. If you're creating multiple profiles and don't know how many there will be you'll probably want to use lists.
epep_dragon
Scratcher
8 posts

Creating profiles

Yeah that's what i was thinking.
But I'm struggling to figure out how to connect the list items with all the scores. Because I want to save scores in lists (probably) for all the profiles that I can draw score history graphs for all the profiles.
So won't I need a separate list for each the profiles to store the scores? If so how do I tell scratch that it needs to generate new lists when new profiles are made?

Last edited by epep_dragon (Oct. 4, 2015 17:10:12)

deck26
Scratcher
1000+ posts

Creating profiles

If each profile has, say, 5 scores then you could use 5 lists. Then for the profile that corresponds to item 1 in the profile name list the first item in each score list corresponds to that user.

If the number of scores for one profile varies and isn't predictable you may need to do something like include the profile number in the data items. For example if each score is a value from 1 to 10 you could add the score to the profile number * 100. So if you see a score like 1506 you know that's for profile 15 and the score is 6. You can combine other information in the same way potentially.

Last edited by deck26 (Oct. 4, 2015 17:39:20)

epep_dragon
Scratcher
8 posts

Creating profiles

Ok so I think I get what you'r saying please check out this program that I quickly threw together to recall scores from a list of users.

https://scratch.mit.edu/projects/80271434/

Probably over complicating it, please tell me where I can shorten it.
deck26
Scratcher
1000+ posts

Creating profiles

You could just use the item number from the profile list rather than include the number as part of those items but what you have will be more robust should profiles ever be deleted.

Your version is slightly different from what I suggested since you're allowing leading zeroes and making your profile numbers therefore have a fixed length but that's fine.

This is a good example of what you could use a custom block for as there's no reason for screen refreshes to take place as you work through the list so a custom block with no screen refresh would speed things up, especially as the list gets longer. Possibly not required if the data set is small.
epep_dragon
Scratcher
8 posts

Creating profiles

I wanted to use the item numbers but then how would scratch recognize the number as part of the profile number, and not the score, once it gets a digit longer, like from 9 to 10?

deck26
Scratcher
1000+ posts

Creating profiles

If the score is a fixed length the rest of the value is the profile number - if score is 2 digits and the list item is 4 characters long the first 2 characters must be the profile number. So if searching for two-digit scores for profile 12 you'd be able to ignore any list items which are not 4 characters long which actually saves time.

Or you could use leading zeroes to store the profile number in the other lists but the actual profile list wouldn't need it as you just copy the item number to a variable and add leading zeroes if necessary before trying to find it in the list items.

What you have is fine though. Being able to delete a profile may be useful to you later - just make sure any new profile has a higher number than the last one. (If you had 25 profiles and deleted number 12 the next one you add either has to reuse 12 or be 26 but its position in the list would be 25.)
epep_dragon
Scratcher
8 posts

Creating profiles

Ok, thanks for your answers!

Powered by DjangoBB