How to add value to webstorage

  • need some help on how to add to webstorage...

    i know how to add as long as game is on... i set my variable to increase by 1 every time player dies and that i send to web storage.

    ...but when i end game and restart mine variable is also reseted so it starts from 0 again... and it sets my web storage to zero.

    in this example i want to count players deaths from the first time ever played to present.

    how can i just add and sum values and increase my webstorage continuusly?

    im trying event like this:

    on player death / webstorage: set local key "destroy" to WebStorage.LocalValue("destroy")+1

    but that +1 is not working...

    help!

  • ok, i solved it... start of layout set my variable to webstorage and closed that circle.

  • If you don't want to reset variables think like this, your key will be "totalDeathsEver" for this example. The value to save on it(your variable) will be playerDeaths.

    When starting the game, first thing to do is to check if there's already a totalDeathsEver key saved. If there isn't you can create it, in case it DOES exist, you set playerDeaths to iqual the value of that key.

    Theres no problem using your logic "set local key 'destroy' to WebStorage.LocalValue("destroy")+1"..as long as you don't reset it

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks ! ! !

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