How do I store arrays away from the save/load feature?

0 favourites
  • 12 posts
From the Asset Store
Template for a generic save / load system, fully documented in comments and video
  • I have 12 slots, all use the integrated system-save/load feature in Construct. I also have an array that is storing all the data about each slot.

    I believe I need to externally store the array and load it in every time a save is loaded- otherwise it will load a previous array state. I know arrays have a download function, but I cannot use that as it actively asks where to be downloaded to. (bad for game saves).

    The reason I use the system save/load is because my game has over 3000 tiles with instant variables packed into them, and i'm not sure anything else could store all that, especially so simply.

    All help is very much appreciatedd.

  • https://www.scirra.com/manual/188/local-storage

    Write Array.AsJSON to a local storage key, which can then be loaded with the array load action.

  • scirra.com/manual/188/local-storage

    Write Array.AsJSON to a local storage key, which can then be loaded with the array load action.

    Apologies for the slow reply, I had a ransomware problem and had to reset my computer.

    Thanks for the help! I will give this a go immediately.

  • What do I do once I have gotten the Array.AsJSON back from the local storage?

    Do I set the array to it somehow? I'm not sure how I would change the array to make it the local storage again.

  • The array has a "Load" action, which you put the JSON string into.

  • The array has a "Load" action, which you put the JSON string into.

    What would the string be please?

    I have entered LocalStorage.Key however it does not work and does allow me to point to a specific key.

  • The string is the Array.AsJSON. Did you read the manual entry about localstorage?

    To retreive a key from local storage, you first check if it exists, then on exists, you get key. Then on get key, you can access it from localstorage.itemvalue.

  • I did but nothing under Arrays was on there.

    My bad, that was the bit I needed thanks. Will say how it goes asap! Thanks.

  • Localstorage can save any value/string, and Array.AsJSON is a string. Localstorage doesn't have anything on arrays in particular because it can be used with many things.

    Array.AsJSON is an array expression, and Load array is an array action, so you can read about them on the array page - https://www.scirra.com/manual/108/array

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Okay it isnt working as is.

    Here is an image of the code and the debug information for the array after save. Loading game currently just loads the array state of that previous state and is not replacing it with the localstorage info (localstorage is untouched too). Same issue without checking the key exists too.

    I have checked and the event- on item get- IS being called, however setting array to key is not.

  • Load from string LocalStorage.ItemValue

  • Brilliant it works thanks for the help! Nailed it completely

    Very happy with it.

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