Where is the "does key exist" for the new local storage ?

Discussion and feedback on Construct 2

Post » Tue Apr 21, 2015 7:02 am

Image

How do you check if a key exist ?
B
12
S
3
Posts: 288
Reputation: 1,694

Post » Tue Apr 21, 2015 1:07 pm

I am in the process of converting all my web storage codes into the new local storage system and is there a way to check if a key exist in the first place for local storage ?
B
12
S
3
Posts: 288
Reputation: 1,694

Post » Tue Apr 21, 2015 1:59 pm

If I may suggest. Use Dictionary for active data. And save the JSON to local storage at reasonable increment times. Then you only need to load data from local storage at the beginning of the game. You will also have access to the standard data check features.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,028

Post » Tue Apr 21, 2015 2:32 pm

Because Local Storage is asynchronous, you have to use the 'Check item exists' action (you're looking at conditions). That then triggers 'On item missing' or 'On item exists'.
Scirra Founder
B
398
S
236
G
88
Posts: 24,428
Reputation: 194,600

Post » Thu Jun 04, 2015 11:52 am

@ashley i am unable to add action check item exists as sub event

i am trying to implement level selection screen as mentioned in below capx example:
https://dl.dropboxusercontent.com/u/635 ... 81%29.capx

please help
B
16
S
4
Posts: 53
Reputation: 1,221

Post » Thu Jun 04, 2015 1:00 pm

i have updated above capx with local storage but still its not working can anyone please check and help me as its a blocker for me now :(
https://dl.dropboxusercontent.com/u/635 ... elect.capx
B
16
S
4
Posts: 53
Reputation: 1,221

Post » Thu Jun 04, 2015 1:32 pm

Event 5 won't work as you are trying to use a trigger as a condition. As suggested above and in the documentation, use a Dictionary to store all of the data as one object. Then you only save/restore that one object, which would work the way you have for 'firstRun'.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494


Return to Construct 2 General

Who is online

Users browsing this forum: Baidu [Spider], sunisa2532 and 25 guests