WebStorage VS Local Storage

0 favourites
From the Asset Store
Basic Plugins for Firebase Authentication, Realtime-Database, Firestore, Cloud Storage
  • Since the latest release introduces Local Storage, I was wandering what is the best way to migrate from WebStorage to the new Local Storage, especially for existing games.

    Thanks

  • The easiest way to do it is probably:

    1. make a dictionary called 'storage' or something

    2. replace all webStorage references with references to that dictionary (or, if you really want to go the extra mile, replace them all with function calls that then reference the dictionary)

    3. save/load the entire dictionary from LocalStorage at specific times (e.g. on startup, on exit, at the start/end of every level, etc).

    That way, you can keep using storage references without needing to worry about the whole async issue.

    Of course, if you are using webStorage to store MB's of information, this approach might not be the best.

  • I'm using x, y, arrays for game "mechanics" so going about using dictionary might be a challenge. Also I'm concern about user existing data that needs to load from Webstorage when the game start.

  • for saving highscore and load it from local storage i prefer webstorage

    i still dont understand the local storage actions

  • What do you need to save in webStorage that you need a whole array of values?

  • One of the arrays I have is with all the game settings like Level, XP points, Items you bought, timestamps erc... I also have X, Y, arrays with more user data.

    Using arrays is much easier that using dictionary as long as you keep a chart with what each value is for

  • You can store arrays in dictionaries! Unpack/pack them during saving/loading.

  • (or, if you really want to go the extra mile, replace them all with function calls that then reference the dictionary)

    Out of curiorisity, why or in what situation would you use that? (I'm still trying to improve my usage of Fuctions.) Thanks!

  • it's an absolute lifesaver when you need to move to a save slots system. All of the webstorage references in Airscape are function calls that pulls the data from the current save slot.

  • Alternatively if you don't need to publish to the Chrome Web Store, just keep using WebStorage. Local Storage is a good idea for the long term and you should use it for any new projects, but if it proves particularly difficult to change over then WebStorage probably isn't going to disappear any time in the foreseeable future. Also if you have already published a game, Local Storage can't read data previously saved by WebStorage, so that might be a dealbreaker.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • it's an absolute lifesaver when you need to move to a save slots system. All of the webstorage references in Airscape are function calls that pulls the data from the current save slot.

    I usually just have a global variable called something similar to "ProfileName" or "SaveSlot", and then if I need a variable (like the HP) from that profile slot I'd just get the value from the key called: ProfileName & "health"

    So I still don't understand the purpose of functions, thanks for answering though!

  • The reason functions are good here is because you know for a fact that you'll never have to go to every instance of a call and change it. For example, say you didn't want "SaveSlot" to be a global variable anymore, but a Webstorage/LocalStorage value. You'd simply have to change one reference in the function, and that's that.

    There are a lot of other reasons functions are cool, but the best way to realize how useful they are is to try and use them!

  • Ashley the data I store in WebStorage is only from arrays, so I'm thinking of a way to migrate.

    When the game start load array data from webstorage and then destroy localkey and save data to Local Storage.

    Next time when game start again - if localkey does not exist look and load data from Local Storage.

    That this sounds about right?

    functions are best used especially when you have parameters, so you can replace the value of an parameter with a variable. (any variable; sprite, text, global variable, local variable ...) Also, if you have a group of actions that get repeated through out your project, functions are the best way to go about.

    What I like to do is have an Event Sheet called "functions" that I import into all the other Event Sheets of my project.

  • Ashley the data I store in WebStorage if only from arrays, so I'm thinking of a way to migrate.

    When the game start load array data from webstorage and then destroy localkey and save data to Local Storage.

    Next time when game start again - if localkey does not exist look and load data from Local Storage.

    That this sounds about right?

    great idea

  • what are local storage actions instead of webstorage ?? (replacement ) for the

    if Local Key "......" exists >>>>> set variable to webstorage.LocalValue('......')

    and

    set LocalKey ".........." to variable????

    thanks ?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)