How do I use an array per save efficiently?

0 favourites
  • 4 posts
From the Asset Store
Per Pixel Destruction like in "Worms" (perfect performance, no third party plugins)
  • I've used arrays for saves, and for saving settings options. These are one array each and work game-wide.

    Within the saves however, a player in the game can create multiple settlements. What I wanted to do so the settlement count is endless and not create a tonne of global variables such as- Settlement10_WoodCount that might not be used- is use an array for that save.

    Is there a way to achieve this? I could pre-make an array for each save slot then clear then save over on every save game, and then have an extra array for unsaved, new games, and have a picker to saveslot for a game = 2 it would save to SettlementsArray2 (assuming that is possible).

    The saves use the Construct save game method- but I believe arrays get around that so having one array with stored values within each save would not work- otherwise the settings array would not be game-wide.

    But is there a better way to do this?

    Thank you.

  • If I understood it, you could also create a dictionary with a key "save2" that will contain JSON.

    Inside your JSON you could have a key "settlements2" and "settins".

    So you will be able to isolate your saves from each other.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I kind of understand what you are saying.

    My saves are isolated and stored using local storage. But will using a dictionary mean i can use one array for multiple saves?

  • Well, you could store dictionaries in arrays and vice versa

    The dictionary and array object have a "load" function, wich needs data served as JSON (previous encoded dictionary or array)

    In short terms, yes, you could load your stored data from localStorage (wich contains a Dictionary.AsJSON) and put that into the dictonary object inside your game.

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