How to write array to localstorage?

2 favourites
  • 9 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I want to write and read array to/from localstorage?

    how to do this?

  • I want to write and read array to/from localstorage?

    how to do this?

    To save it just set "LocalStorage -> Set key [key] to [Array.AsJSON]

    to load it fetch the key and set load the array like

    On LocalStorage Item get => Array => Load From JSON [LocalStorage.ItemValue]

    Regards

    Andy

  • > I want to write and read array to/from localstorage?

    > how to do this?

    >

    To save it just set "LocalStorage -> Set key [key] to [Array.AsJSON]

    to load it fetch the key and set load the array like

    On LocalStorage Item get => Array => Load From JSON [LocalStorage.ItemValue]

    Regards

    Andy

    Hey - thanks for this!!! You just saved me a day of work

  • >

    > > I want to write and read array to/from localstorage?

    > > how to do this?

    > >

    >

    > To save it just set "LocalStorage -> Set key [key] to [Array.AsJSON]

    >

    > to load it fetch the key and set load the array like

    >

    > On LocalStorage Item get => Array => Load From JSON [LocalStorage.ItemValue]

    >

    > Regards

    > Andy

    >

    Hey - thanks for this!!! You just saved me a day of work

    Sure, you're welcome

    Regardas Andy

  • Can you use the third dimension of the array as well?

  • yes, the whole array is converted to JSON and saved/loaded as a single string.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • > I want to write and read array to/from localstorage?

    > how to do this?

    >

    To save it just set "LocalStorage -> Set key [key] to [Array.AsJSON]

    to load it fetch the key and set load the array like

    On LocalStorage Item get => Array => Load From JSON [LocalStorage.ItemValue]

    Regards

    Andy

    I'd like to know if I did this correctly:

    System | On start of Layout = LocalStorage | Set item "key" to LevelArray.AsJSON

    LocalStorage | On item "key" get = Array | Load from JSON string LocalStorage.ItemValue

  • Please see this demo on how to use Local Storage correctly and save/load array data.

    howtoconstructdemos.com/easily-save-multiple-values-in-local-storage

  • Please see this demo on how to use Local Storage correctly and save/load array data.

    https://howtoconstructdemos.com/easily-save-multiple-values-in-local-storage/

    Very Helpful. Thank you!

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