LocalStorage.ItemValue...

0 favourites
  • 6 posts
  • In regards to Local Storage items, I have two for the Highscore and the Number Of Rounds...

    LocalStorage > on item "highscore" exists > LocalStorage > Set item "highscore" to HighScore

    LocalStorage > on item "highscore" exists > System > Set Highscore to LocalStorage.ItemValue

    ...and...

    LocalStorage > on item "numberofrounds" exists > LocalStorage > Set item "numberofrounds" to HighScore

    LocalStorage > on item "numberofrounds" exists > System > Set NumberOfRounds to LocalStorage.ItemValue

    Both the Highscore and Number of Rounds being recorded taken through to the Game Over screen and displaying correctly. However, when I quit the game and restart, only the High Score is saved and displays again but the Number of Rounds is reset to zero.

    So in regards to LocalStorage.ItemValue - are you only allowed one or can you have multiple? It's also quite possible that the rest of the my code is missing something so Im not ruling that out yet.

    Cheers all

  • This...

    LocalStorage > on item "numberofrounds" exists > LocalStorage > Set item "numberofrounds" to HighScore

    LocalStorage > on item "numberofrounds" exists > System > Set NumberOfRounds to LocalStorage.ItemValue

    should be...

    [quote:1zl5foee]LocalStorage > on item "numberofrounds" exists > LocalStorage > Set item "numberofrounds" to NumberOfRounds

    LocalStorage > on item "numberofrounds" exists > System > Set NumberOfRounds to LocalStorage.ItemValue

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This...

    > LocalStorage > on item "numberofrounds" exists > LocalStorage > Set item "numberofrounds" to HighScore

    > LocalStorage > on item "numberofrounds" exists > System > Set NumberOfRounds to LocalStorage.ItemValue

    >

    should be set to ...

    [quote:38wxoyg8]LocalStorage > on item "numberofrounds" exists > LocalStorage > Set item "numberofrounds" to NumberOfRounds

    LocalStorage > on item "numberofrounds" exists > System > Set NumberOfRounds to LocalStorage.ItemValue

    Yep - sorry, that's me cutting/pasting from the top example to the bottom. The current code I have is:

    LocalStorage > on item "highscore" exists > LocalStorage > Set item "highscore" to HighScore

    LocalStorage > on item "highscore" exists > System > Set Highscore to LocalStorage.ItemValue

    ...and...

    LocalStorage > on item "numberofrounds" exists > LocalStorage > Set item "numberofrounds" to NumberOfRounds

    LocalStorage > on item "numberofrounds" exists > System > Set NumberOfRounds to LocalStorage.ItemValue

  • I have no problems using multiple local storage items in my projects. You probably overlooked something simple, like not having 2 different keys or values to correspond to each item. Can you share a project file or a screenshot of the events?

  • Here's the opening of the Game page where NumberOfRounds appears:

    And here's the Game Over page where the NumberOfRounds is pulled in:

    Any ideas?

  • Try adding a...

    [quote:1buxwtrf]LocalStorage > on item "numberofrounds" missing > LocalStorage > Set item "numberofrounds" to NumberOfRounds

    To force local storage to create it if it's missing.

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