How do I LocalStorage NaN Error (SOLVED)

Get help using Construct 2

Post » Sat May 21, 2016 5:07 pm

I've been at this for 4 days and I can't figure out what I did wrong. I actually had it working, but tried to add some custom fonts and it went crazy. I was able to get it back to "0" which meant it was at least reading it, but now I'm just getting an NaN result when I call the LC for the text.

http://www.tiikoni.com/tis/view/?id=6764623

Am I missing something???

Thank you in advance for your help.
Last edited by ALLMarkMade on Sun May 22, 2016 12:02 am, edited 1 time in total.
Check out my latest game RAPID-TAPIT. Get your Fingercise on with this one. A steady Tap is all you need to score points. Lift a finger and see what you can do...

Image

ALLMarkMade Designs
B
39
S
19
G
4
Posts: 366
Reputation: 6,368

Post » Sat May 21, 2016 5:36 pm

Try to set text to "some text"&str(variable)
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat May 21, 2016 6:52 pm

@99Instances2Go - Thanks but that didn't do anything. It's almost like the value for the keys are not being stored. I have an older version of my game from when I first did the local storage and it works fine. This is a copy of that and it will not work. The text goes immediately to NaN when it at least to display "0". I don't know what changed.

Does anyone see anything missing from the code I posted??? This should work, right?

Thanks
Check out my latest game RAPID-TAPIT. Get your Fingercise on with this one. A steady Tap is all you need to score points. Lift a finger and see what you can do...

Image

ALLMarkMade Designs
B
39
S
19
G
4
Posts: 366
Reputation: 6,368

Post » Sat May 21, 2016 8:41 pm

When NaN gets displayed it usaly means that you tried to assign a wrong type of value to something.

But i dont see that in de your code. I dont see see anything wrong in storing/getting.

There is one thing more i can suggest. Assign a 'Clear storage" to a key press. Run it. Press the key. Quit it. Try again.

This will heal a corrupt local storage. We all code with try and error. With each version the local storage gets weird. This will also clear a full local storage.

Hope that helps you out.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat May 21, 2016 9:46 pm

@99Instances2Go - Cool thank you I will and you might be correct, I have about 20 version and I made a lot of tests and changes so it could have very well gotten corrupted...

Thank you, I'll let you know....
Check out my latest game RAPID-TAPIT. Get your Fingercise on with this one. A steady Tap is all you need to score points. Lift a finger and see what you can do...

Image

ALLMarkMade Designs
B
39
S
19
G
4
Posts: 366
Reputation: 6,368

Post » Sat May 21, 2016 10:32 pm

NaN means "Not a Number".

Where do you get this message ?

From the events in the picture the most likely position to get this message from is setting the maxScore to the itemvalue, meaning the itemvalue likely does not exist. If you check the debugger, the global variable maxScore probably displays NaN as value, which you then display in the text box.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Sun May 22, 2016 12:02 am

Yep! @99Instances2Go - FIXED!!!! I just need to give it a little love after pushing it so hard.... Thanks for the look @lennaert but clearing the Storage did the trick.

Now after 4 days of fussing, I can get back to business.

Thank you
Check out my latest game RAPID-TAPIT. Get your Fingercise on with this one. A steady Tap is all you need to score points. Lift a finger and see what you can do...

Image

ALLMarkMade Designs
B
39
S
19
G
4
Posts: 366
Reputation: 6,368


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 62 guests