Hey, Turtle-Coder here. A couple of my games store statistics by recording it in a variable. The only way to set the variable back to zero is by resetting the data. I did this in Water & =Run and Space Defender. However, if the player gets off the project, all stats are reset. My question is how would you keep the data intact when the player gets off the game? I'm not a really good coder, so your answer will help me get better. Thank you for your time!
You can use the database library to store data in the browser.
Thanks. I'm sure that will definitely work, except being the primitive coder I am, I've never used the library blocks. I'm sure I'll eventually figure what these new blocks do. Thank you!
THANK YOU! THANK YOU! THANK YOU! It works! I had to look at the code of the game Clickr to see how the blocks worked, but they work. Thanks so much!
Do you know why when the game stores data it randomly changes the value to a Boolean? It's only happening in my Water & =Run game for some reason to the values Mutant Plants Killed and Longest Game(Sec). you can look at my code to clear things up. Search Water & =Run on the community page and it should be the only project to show up.
This is because the dictionary keys aren’t case sensitive and if you try to report a key that doesn’t exist it gives you a false booleen, so if you store something in “Apple” and then get “apple” it will report false (unless something is already stored in “apple” obviously)
Case sensitive means that capital letters are accounted for if you didn’t know
The mechanism of a data item's unavailability being signified by a can only work because of the library's undocument limitation of domain to text and numbers only. This leaves room for improvement .
Is expansion to other data types being worked on yet? (@bh, I guess)
Id honestly have no idea if that’s possible because snap data types are pretty arbitrary (at Least in this context)
I don’t think the browser storage can do much more than just strings so something like storing a sprite in there would be impossible
All data can in principle be translated to strings, and vice versa.
Yea that’s true.
But my main concern is how list encoding would be handled
How do you distinguish between a “space” (indicating the next list item) and a list item that contains a “space?”
(Space could realistically be any character)
No matter what you do a list could still have an item that contains the specific distinction that the encoder would use
Storing a list would be the vary basic thing needed to store anything in snap, as you could store a sprite as a list of its scripts, name, costumes, parents, ect.
Any data type could be at the very least be translated into a list
For example while it would be very innifeceent, you could store a costume as a list of rgb values (like the pixels of block) and then store that
Just store a list in json format, then to get it back, just split by json.
But what if the list itself is formatted like a json
It's still work, json is just a way to represent lists as text, and be able to get the list back, no matter how the data is stored.
My bad. Thank you. I thought the keys were the same, but k in Mutant Plants Killed wasn't capitalized and I put a space in Longest. Thanks for the help!
My brother is telling me to tell you that he fixed it.
when you ask for help on a Snap! project, it should probably go in "Help with Snap editor" instead of requests to the community
Thank you. I'll do that next time!
you can change it if you click the pencil button on the topic post
I’ll try that