Local Storage not setting value to variable on start of layout

0 favourites
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • What could possibly be wrong here?

    Tagged:

  • Either it doesn't exist or the saved value is 0 so when it gets it there is no difference. Do something with 'on item missing' to see if this is the problem.

  • Will do. I’ll report back later.

  • What could possibly be wrong here?

    Hi. I think you should change the comparison sign.

    In your case, event number 56 repeats about 60 times per second.

  • You can always check what is in your local storage in debug mode.

  • You can always check what is in your local storage in debug mode.

    The problem is that the LocalStorage gets reset after dying a second time. Basically to test if it was working I would make 2 or 3 points, then do a new game without doing any points to just see if the High Score would be saved.

    The problem is the High Score value inside the Local Storage getting set to the Score value even if it is less than the High Score.

  • It's more than likely that Local Storage doesn't write the value inside the HighScore variable, thus leaving it at zero and as a result the Local Storage sets itself to 0 when you play a second time.

  • Update: Local Storage writes the value inside the variable. It only gets reset after a game over.

    I'm going crazy trying to figure out why 😩

  • So did you confirm if it is setting high score correctly from local storage on game launch yet ?

    There is a potential bug if game over is set to 1 on game launch but my assumption is it's set to 0 and you set it to 1 when you die.

  • I'm going crazy trying to figure out why 😩

    kibaga.org/c3-example/file_uploads/index.php

    Maybe this simple example will help you.

    Local storage works simply and is well documented.

  • So did you confirm if it is setting high score correctly from local storage on game launch yet ?

    I can confirm that the Local Storage value is set correctly after a new game starts. It gets reverted to 0 if a game over happens after a new game is started though.

    There is a potential bug if game over is set to 1 on game launch but my assumption is it's set to 0 and you set it to 1 when you die.

    You are correct, I set game over to 1 if you die but it gets reverted to 0 on a new game.

  • If it gets reverted to 0 after a game over, then at what point is it saving correctly ? Because after a game over is the only time we see you save it. I would maybe share the file at this point.

  • If it gets reverted to 0 after a game over, then at what point is it saving correctly ? Because after a game over is the only time we see you save it. I would maybe share the file at this point.

    The GameOver variable gets reverted to 0 after Local Storage is saved.

    The issue is that after the second game over it gets reverted to 0 with no apparent reason.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here’s the project file: 1drv.ms/u/s!AlJYp-O5xIwQ8BsOkfVpv6C84MYN

    Let me know if the link works.

  • Event 55, it says set highscore to score without any condition, so it always changes the high score even if the score is lower.

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