How do I use an array per save efficiently?

Get help using Construct 2

Post » Sun Jun 25, 2017 11:12 am

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.
- Head of Tall Story Studios.

Creator of GOV, Project Abyss, Spiritlands & more!
B
27
S
12
G
1
Posts: 129
Reputation: 3,064

Post » Sun Jun 25, 2017 12:36 pm

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.
B
22
S
7
G
1
Posts: 13
Reputation: 2,212

Post » Sun Jun 25, 2017 1:43 pm

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?
- Head of Tall Story Studios.

Creator of GOV, Project Abyss, Spiritlands & more!
B
27
S
12
G
1
Posts: 129
Reputation: 3,064

Post » Mon Jun 26, 2017 3:21 pm

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.
B
22
S
7
G
1
Posts: 13
Reputation: 2,212


Return to How do I....?

Who is online

Users browsing this forum: adventurist, Artcadev, Blendi1223, PROxMTswatTR and 27 guests