How do I LocalStorage NaN Error (SOLVED)

0 favourites
  • 8 posts
From the Asset Store
Use this game pack to create your own game, modify the existing game or simply take a look and see how it was made.
  • 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.

  • Try to set text to "some text"&str(variable)

  • 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

  • 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.

  • 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....

  • 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.

  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the trick.

    i was realize that i put the localstorage some string value.

    because i found that i use "" inside LocalStorage set item

    when On Item "key" Missing

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)