Save array information

Get help using Construct 2

Post » Wed Apr 24, 2013 12:32 pm

I just tried to export my game with the webnode kit.

The thing is.. As long as I am in the game, the array information works fine between Layouts. But when I exit the game and start again... All the chosen information is lost.

Maybe I misunderstood the use of arrays. Is it not supposed to store the information somewhere in the file?
B
9
S
4
G
1
Posts: 102
Reputation: 2,274

Post » Wed Apr 24, 2013 12:44 pm

Yup, arrays themselves don't save the data between restarts. Look into web storage object, that would probably work for you.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Wed Apr 24, 2013 12:50 pm

To save
On Trigger -> WebStorage: Set local key "x" to "y".AsJSON

to load
WebStorage: Local key "x" exists -> "y": Load from JSON string WebStorage.LocalValue("x")


Trigger - condition where You want to save your array (On button press, On collision...)
"x" - name of the local value you want to save (can be anything "aaa", "save"...)
"y" - Array object
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Wed Apr 24, 2013 1:14 pm

So... If I use the web storage, I will have to ditch my arrays and arrange the values in web storage instead?

There must be a way to save array information between sessions or the world will implode. WizLore2013-04-24 13:31:17
B
9
S
4
G
1
Posts: 102
Reputation: 2,274

Post » Wed Apr 24, 2013 1:40 pm

You can save your arrays as JSON, and put the JSON into a webstorage key as shinkan suggested.

B
44
S
13
G
7
Posts: 338
Reputation: 10,379

Post » Wed Apr 24, 2013 2:36 pm

Thanks for cutting it out for me Zatyka... I get it now! :)
Ty for the replies all.
B
9
S
4
G
1
Posts: 102
Reputation: 2,274

Post » Sun Jun 23, 2013 5:30 am

Using Haematite's post, the capx I downloaded works. But using the same events in my project and a little test layout will not work. It returns as if no data was saved.

Can Anyone tell me what I am doing wrong? Is it case sensitive?







Thanks, Ed
B
16
S
2
G
1
Posts: 35
Reputation: 1,033

Post » Sun Jun 23, 2013 5:33 am

It appears My image link is rejected also. :(

http://justpaste.it/2wnd

http://justpaste.it/2wnd

<a href="http://justpaste.it/2wnd">http://justpaste.it/2wnd</a>
B
16
S
2
G
1
Posts: 35
Reputation: 1,033


Return to How do I....?

Who is online

Users browsing this forum: jeffige and 1 guest