How to add value to webstorage

Get help using Construct 2

Post » Mon Mar 31, 2014 8:51 pm

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!
B
29
S
11
G
2
Posts: 692
Reputation: 5,159

Post » Mon Mar 31, 2014 9:00 pm

ok, i solved it... start of layout set my variable to webstorage and closed that circle.
B
29
S
11
G
2
Posts: 692
Reputation: 5,159

Post » Mon Mar 31, 2014 9:04 pm

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
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Tue Apr 01, 2014 9:06 am

Thanks ! ! !
B
29
S
11
G
2
Posts: 692
Reputation: 5,159


Return to How do I....?

Who is online

Users browsing this forum: Cryttexx, Yahoo [Bot] and 19 guests