Discuss Scratch

GoldenretriverLP
Scratcher
17 posts

Local Storage function

How about a local storage function? This would make it possible to save data.
rdococ
Scratcher
1000+ posts

Local Storage function

I'm not sure if I support or not, but here are some possible workarounds.

Passwords

This one works best with simple games where all you need to save is a level number. You can use a unique password for each level. When the player reaches a new level, they get the password for the new level, and when they come back to the project they would be able to enter the password to skip to that level. If you want to save anything more, such as a score, you'll need some kind of encoding and decoding system.

Project saving

Ask the player to save the project as an unshared remix. This makes it very easy to save lots of stuff, such as an inventory, score, position, and so on. However, if you make changes to your project, it won't update those changes in existing saved games.

duckboycool
Scratcher
1000+ posts

Local Storage function

It is also already possible to do so with cloud variables, although they are quite limited as of now.
CKCG
Scratcher
100+ posts

Local Storage function

This is definetly a duplicate, I'm just not sure where from. I'm using list reading and writing for saving in my current game project.
BlastikGames
Scratcher
100+ posts

Local Storage function

GoldenretriverLP wrote:

How about a local storage function? This would make it possible to save data.

I Have been SCREAMING MY FACE OFF at scratch about this. it is no use
GoldenretriverLP
Scratcher
17 posts

Local Storage function

CKCG wrote:

This is definetly a duplicate, I'm just not sure where from. I'm using list reading and writing for saving in my current game project.
I never saw a thread about this.
GoldenretriverLP
Scratcher
17 posts

Local Storage function

CKCG wrote:

This is definetly a duplicate, I'm just not sure where from. I'm using list reading and writing for saving in my current game project.
And cloud lists don't work at the moment, at least for me…
Wasn't there a new limitation for cloud variables, that made cloud lists impossible?
CW_school
Scratcher
46 posts

Local Storage function

LocalStorage
I would love to see a block that allows a project to store information in a browsers local storage. This would allow projects to know if a user has been to that project before, let them know of updates and to store personal highscores etc..
Examples:
set [hasViewed] to [Yes] in [localStorage v]

set [personalBest] to [100] in [localStorage v]
The way to store data could be very simple, as the key would be the project ID. Local storage isn't secure in which a script could manipulate the values, so nothing should be stored that shouldn't be changed by the user.

Then another block would be able to pull a value out of the localStorage like below, but would not be able to pull information that was stored from another project:
(get [personalBest] from [localStorage v])
The data stored in the localStorage could be stored as an object:

projectId = {“hasViewed”: “Yes”, “personalBest”, 100}

That could then be pulled out using JSON.parse():
var data = JSON.parse(localStorage.getItem('projectId'));
console.log(data.hasViewed);

Would log: “Yes”

Also, there could be a way to allow your project localStorage to be accessed by other projects, whether it's some form of data stored on Scratch Servers, or just a special tag in the description of a project, it would allow projects to interact with each other, and share data.

Last edited by CW_school (July 19, 2019 02:26:58)

CW_school
Scratcher
46 posts

Local Storage function

SessionStorage
Works the same as localStorage except it automatically gets removed upon the browser session closing.
set (foo) to (foo) in [sessionStorage v]
get (foo) from [sessionStorage v]

Cookies
Cookies are similar to localStorage and sessionStorage but they can have custom expiration dates added.
The block would be more complicated.
//Ways of setting cookies
set (foo) to (foo) that expires at yr(2019) m(12) d(31) t[12:00] in time zone [EST v]
set (foo) to (foo) that expires at [12:00pm] [EST v] of [12/31/19]

//Get cookie
get (foo) from [cookies v]

There are definitely better ways to set cookies.

NOTE cookies come with there risks

bybb wrote:

LocalStorage and SessionStorage are a good idea, but cookies are dangerous because, if implemented wrong, would allow projects to leak your CSRF token and Session token.

Last edited by CW_school (July 20, 2019 01:35:18)

bybb
Scratcher
1000+ posts

Local Storage function

LocalStorage and SessionStorage are a good idea, but cookies are dangerous because, if implemented wrong, would allow projects to leak your CSRF token and Session token.
CW_school
Scratcher
46 posts

Local Storage function

Yeah… Someone could create a project with a get cookie block that would get your tokens and store them in a cloud variable, stealing them…. Cookies are definitely come with there risks.
Luvexina
Scratcher
500+ posts

Local Storage function

AFNNetworkK12
Scratcher
1000+ posts

Local Storage function

VFDan wrote:

Duplicate
It also suggests other stuff
CW_school
Scratcher
46 posts

Local Storage function

Bump
LuckyLucky7
Scratcher
1000+ posts

Local Storage function

CW_school wrote:

Bump
Sorry, but if this topic is a duplicathe, you might as well close it and post on the other topic(mentioned in the posts above), unless you are trying to suggest something else.
CW_school
Scratcher
46 posts

Local Storage function

I wouldn't consider this a duplicate because I have explained how this could be implemented… Bump
GoldenretriverLP
Scratcher
17 posts

Local Storage function

It would be nice to have the ability to save data to local storage.
It would be a easy method to add saving to the project, for creators and the scratch team.

The LocalStorage-JS-Methods are super simple:
localStorage.setItem(“key”, “value”);
localStorage.getItem(“key”);
GoldenretriverLP
Scratcher
17 posts

Local Storage function

Any responses?
DaBestCoding
Scratcher
31 posts

Local Storage function

I like It
PumpkinBear111
Scratcher
68 posts

Local Storage function

What would this be used for? Please explain some more.

Powered by DjangoBB