How do I used webstorage ?

Get help using Construct 2

Post » Fri Oct 24, 2014 4:11 am

Hello,
I'm using webstorage to save the best score of my game, but I don't understand, in my localhost it works perfect!, but when I published my game on a server, it only got a zero (like if the data couldn't be load nor saved)...

what would it be ?...
webstorage works on remote ?....
thank you very much.
B
21
S
3
G
2
Posts: 86
Reputation: 2,262

Post » Fri Oct 24, 2014 6:47 am

webstorage stores data in the browser, not in a server as far as I know, if you save it local it will stay there until the browser's cache/cookies is cleaned, if saved session, data will be lost when closing the browser
Image
B
58
S
13
G
6
Posts: 271
Reputation: 12,128

Post » Fri Oct 24, 2014 8:12 am

I think the answers are in the manual https://www.scirra.com/manual/120/webstorage

"The WebStorage object can store data locally on the user's computer"

"WebStorage does not store in the browser cache."

"if the user opts to clear all their cookies or offline website data, WebStorage will be cleared. "
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Oct 24, 2014 2:23 pm

Thanks for your replies...
I think, I didn't explain it well. I've already known web storage stored data in the local computer (client that is playing), but my problem is that when I test my game on my localhost (run from construct2) webstorage works fine. But if I compile (as HTML5 for example) and then I upload the code to my game server, and I play it from my computer then the web storage doesn't work and I don't understand why, all I've got is a zero as value.
B
21
S
3
G
2
Posts: 86
Reputation: 2,262

Post » Fri Oct 24, 2014 3:30 pm

Try running the compiled version on your localhost...

The next option would be to post your capx file here...

What is showing a zero value and when? Something at the start of the game - the high score, player score or lives or something else never change?

When, where, how do you need this zero value to change?
B
11
S
2
Posts: 46
Reputation: 739

Post » Sat Oct 25, 2014 5:52 pm

Hello maxxscape, thanks for your answer...
I tried to run the compiled version... but it doesn't work on localhost.
The zero value is showing on a text object that shows the best score, the condition is that on start of layout (you can see in the atachment).
I'm using it to store the high score of the player.
This text could change to "Your best score: X"...

I saw another thing, if I use firebug I can see this error:

"Application Cache Error event: Manifest fetch failed (404)"
what does it mean ?...

thank you very much.
You do not have the required permissions to view the files attached to this post.
B
21
S
3
G
2
Posts: 86
Reputation: 2,262


Return to How do I....?

Who is online

Users browsing this forum: richardfu and 37 guests