How do I load a saved array?

Get help using Construct 2

Post » Fri Apr 08, 2016 8:40 pm

Hi everyone,

I was following the tutorial "Array for Beginners" by Ramones.
https://www.scirra.com/tutorials/307/ar ... ers/page-3

This tuto is old and uses Web Storage that has been replaced by Local Storage.

I was able to save the array in the local storage but I can't load it!

Here is what I have done:

On saveArray Button clicked ---> LocalStorage ---> Set item "01" to animals.AsJSON
On loadArray Button clicked ---> (Array) Animals ---> Load from JSON string "01"

I was expecting the entry text that displays what is in your array be filled by the Array loaded?
What should I do?

Thank you for your help
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Fri Apr 08, 2016 9:41 pm

Local storage
Manual wrote:Local Storage is asynchronous. This means reading and writing data does not complete immediately. The actions only start the process of reading or writing a value, and the game continues to run in the interim. This ensures that slow or busy storage systems do not impact the performance of the game. When the read or write is complete, a trigger fires (On item get or On item set) which indicates either the value is available to read (with the ItemValue expression) or that the value was successfully written.

For example here is a flow to read the value of the key "score":

1.Use the action Get item "score"
2.A moment later, On item "score" get triggers
3.In this trigger, use the ItemValue expression to read the item


Image
B
66
S
24
G
7
Posts: 1,514
Reputation: 11,039

Post » Fri Apr 08, 2016 10:24 pm

Thank you Korbaach, your help was useful I understood the concept. It works well!
B
26
S
10
G
3
Posts: 72
Reputation: 4,008


Return to How do I....?

Who is online

Users browsing this forum: ST314, ultrafop, Yahoo [Bot] and 30 guests