What am I doing wrong with WebStorage?

0 favourites
  • 10 posts
From the Asset Store
Be quick and choose whether the shown equation is right or wrong.
  • Hello, I read/watched a bunch of text/videos on the topic of webstorage and saving the highscore, but I cannot get it to work myself. I attached a screenshot of the code that I am using and to me it makes perfect sense and should work, but when I refresh the webpage of my game the high score value just goes back to 0. Could it be that the webstorage doesnt work when testing the game directly from construct 2 or am I just making an epic mistake?

    Thank you

  • Hi,

    not sure, but try to cast webstorage.localValue to int..

    Then you checks will be

    HighScore < int(WebStorage.LocalValue())..

  • nope doesnt solve the problem, but thanks for the reply

  • localvalue("Highscore")

    mind the qoutes

  • Still doesnt work, could it be that webstorage doesnt work in browser?

  • Post a screenshot of what you have now.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No in your example, you did not use qoutes in referencing the name of the variable.

    You use the variable reference Highscore as the name.

    for instance

    variable Highscore = 1000

    And you do Highscore >= webstorage.LocalValue(Highscore)

    That means your doing:

    Highscore >= webstorage.LocalValue("1000")

    Menaing you are referencing a variable called "1000" in the webstorage, while you should be refering to its name, getting you the value of the local stored "Highscore".

    And yes, web storage .... is used for storing in the web browser ....

  • i dont think so because my global variable for the highscore is "HighScore" but the localvalue is "Highscore" the S is lower case. Would that sill make it not work?

  • i dont think so because my global variable for the highscore is "HighScore" but the localvalue is "Highscore" the S is lower case. Would that sill make it not work?

    I was not referring to the upper or lower case ....

    In your first image, there are 3 locations where you pass the content of your Highscore variable as the name of the local variable in webstorage.

  • Thank you! I was missing the """""" I solved my problem )

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