How do I Save and Load an Array in a Dictionary?

0 favourites
  • 4 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hello,

    First time posting. Working on my first Construct (C3) project and want to be able to save some game settings include a top ten scores (with names and rank). I'm close to done but run into a problem with saving the score data.

    I've got how to save and load standard variables in a dictionary but after spending more time than I'm willing to admit, I can't figure out how to do the same for a 3w x 10h array (after reading the manual about local storage, arrays, and JSON). It looks like the array data gets stored in the dictionary but I can't get loaded back out into the array at next load, even though the data is there.

    Here's a screenshot of the code I put together just for testing arrays and localstorage.

    If anyone can provide any assistance I'd be grateful.

    Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You made a typo in the key name - "Array_Scores" and "ArrayScores"

  • Oh my! I think I need new bifocals! I went through that so many times and thought I had caught the simple things. Alas, I had the "big" things correct for quite a while, and a "simple" thing wrong, LOL. SMH.

    Just tested after making that simple fix and it works fine. Thanks very much for catching that!

    Well, at least anyone running across and reading this post/thread now has an example of at least one way of saving an array in a dictionary and then loading it.

    Thanks again!

  • If anyone wants the c3p file the link to it follows. It should at least provide a good experimentation base like it did for me. Looking at what goes on in debug was really helpful for me. Anyway... for what it's worth... here it is.

    https://1drv.ms/u/s!AubAbM0oOIrcg4h1cDuZeNLGdCghhw?e=2upaTQ

    Here's the new image with the corrected code.

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