Save in Array or Global Variable?

Just started using Construct 2? Post your questions here

Post » Tue May 26, 2015 4:03 pm

Is there a difference if I save values/stats in an Array or a Global variable.

I find it convenient that I can save multiple values in an Array and save that one Array in Webstorage, over having to save multiple Global variables in Webstorage.

So is there any benefit of one over the other?
B
16
S
4
Posts: 138
Reputation: 1,454

Post » Thu May 28, 2015 8:37 pm

Webstorage is depreciated and LocalStorage now seems to be the way forward. One of the differences between the two is that Local storage loads and save values asynchronously (ie each value individually) so storing the values in an array would simplify checking whether all values had been loaded.
B
13
S
2
G
1
Posts: 22
Reputation: 760

Post » Fri May 29, 2015 6:40 am

As a further possibility:
I save all consistent values to an Object from my "Tools" plugin.

Image

Image

I have modyfied it, but based on:
http://stackoverflow.com/questions/6491 ... string-key
and json strings.

So you can save all vars in one string whereever you want and load them as easy.
Sorry for my bad english, but I really do my best! And use and check with Google Translator.
B
10
S
4
G
1
Posts: 158
Reputation: 1,303


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests