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

Get help using Construct 2

Post » Fri Mar 24, 2017 7:08 pm

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

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

Post » Fri Mar 24, 2017 10:38 pm

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.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,697
Reputation: 64,442

Post » Mon Mar 27, 2017 9:07 am

oosyrag wrote: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.


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

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

Post » Tue Mar 28, 2017 3:13 pm

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

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

Post » Tue Mar 28, 2017 3:39 pm

The array has a "Load" action, which you put the JSON string into.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,697
Reputation: 64,442

Post » Tue Mar 28, 2017 3:44 pm

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

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

Post » Tue Mar 28, 2017 3:51 pm

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.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,697
Reputation: 64,442

Post » Tue Mar 28, 2017 3:54 pm

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

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

Post » Tue Mar 28, 2017 4:31 pm

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
Mistakes were made.
B
53
S
27
G
114
Posts: 1,697
Reputation: 64,442

Post » Tue Mar 28, 2017 4:44 pm

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.

Image
- Head of Tall Story Studios.

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

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests