How do I correct my local storage script. Simply not saving

Get help using Construct 2

Post » Wed Oct 07, 2015 12:48 pm

So all is in the images. I can't get why local storage don't react. (Clear local storage action for debug only)
1
Image
2
Image
And 3rd image shows that local storage later in game creates NOT A NUMBER values when supposed to be 0 or more. But at least it reacts with same actions I used on picture 1.
3
Image
Local storage Looses and Matches on this pic have NaN values.>^^^^^^^^^^

Help please. And thanks for your time.
P.S. All was done after reading guide https://www.scirra.com/tutorials/1461/h ... age-plugin , so please dont send me there.
B
9
S
1
Posts: 65
Reputation: 861

Post » Wed Oct 07, 2015 1:57 pm

You need to call "Check item exists" on Wins, to get the ball rolling.
ImageImageImage
B
71
S
22
G
259
Posts: 3,794
Reputation: 143,704

Post » Wed Oct 07, 2015 2:06 pm

OnStart you have it clearing the storage. Try assigning a key to the clear storage action rather than OnStart and see if that helps.

Small tip, to speed things up, load everything into an array, and save the arrays .json string rather than having 3 or 4 separate keys. This should make loading everything a bit easier too.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Wed Oct 07, 2015 2:15 pm

OK. But I sayed that clearing the storage is for debug only, normally it dont presist in project, but still was same result.
B
9
S
1
Posts: 65
Reputation: 861

Post » Wed Oct 07, 2015 2:23 pm

It has nothing to do with the clearing of the storage..
like @blackhornet says, add the "check item exists" event..

You won't know if something (in your case "Wins") is missing unless you check if it exists..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Oct 07, 2015 2:28 pm

Its wary strange but this fixed the problem
Image
All this LocalStorage thing is really unpolished.
B
9
S
1
Posts: 65
Reputation: 861

Post » Wed Oct 07, 2015 2:38 pm

That's a convoluted way of doing it. Maybe describe what you want to happen. There are simpler ways of doing what we can see, but we don't know what is going on elsewhere.
ImageImageImage
B
71
S
22
G
259
Posts: 3,794
Reputation: 143,704

Post » Wed Oct 07, 2015 3:48 pm

It is ok now. My aim for now is not an optimisation. I am doing simple tic-tac-toe game for mobile devices. More of aim to study and practise, but I added global tracking of win, loose, matches like highscore, and some AI. Optimisation for me now is not critical.
P.S. I already have 151 event in tic-tac-toe))))
B
9
S
1
Posts: 65
Reputation: 861

Post » Wed Oct 07, 2015 5:49 pm

And it broke again somehow T_T. Will try to save in json
B
9
S
1
Posts: 65
Reputation: 861


Return to How do I....?

Who is online

Users browsing this forum: BiffanyPFH, Klarner and 22 guests