Understanding Webstorage

Discussion and feedback on Construct 2

Post » Tue Mar 04, 2014 9:27 pm

Ok I have a question about the webstorage so I can better understand. I created the 'highscore' and 'name' key that is used on the website. Here is the scenario-

I load up the game in firefox and made the new hi score and its stored. When I don't beat the hi-score it shows me what the current high score is and the person name. Fine right...well load up the same app in IE and played my score was lower than the high score I got in firefox but the application in IE says that it was the new hiscore. So I go back to firefox and I purposely lose as to not to beat any of the scores, it shows what the current high score is what I first made in firefox and not the IE score which was lower . But go over to IE do the same it shows the score that I got in IE not the firefox score which is the highest of the two. Does the webstorage create different file for each browser??
Last edited by PhoenixNightly on Tue Mar 04, 2014 10:10 pm, edited 1 time in total.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Tue Mar 04, 2014 9:38 pm

Webstorage is not shared between browsers.
Image ImageImage
B
170
S
50
G
179
Posts: 8,378
Reputation: 113,425

Post » Tue Mar 04, 2014 10:09 pm

Ah OK is there a way to store score to make it universal through browsers??
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Tue Mar 04, 2014 10:59 pm

Either from a server, or a service, such as clay.io, or gamejolt.com.
Image ImageImage
B
170
S
50
G
179
Posts: 8,378
Reputation: 113,425

Post » Wed Mar 05, 2014 2:54 am

Clay.io can upload/download save files with the user logged.
It's not possible (and unsafe) share storage between browsers.
Image
B
26
S
10
G
5
Posts: 25
Reputation: 3,130

Post » Wed Mar 05, 2014 5:04 am

I see. Thank you both newt and Keyo. I will have to find other means of doing this at a later time. Was just a test project to get myself familiar with C2 since I am new.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Wed Mar 05, 2014 5:48 am

@PhoenixNightly
This is amusingly sad and by no means your fault. Many of us mid and older developers have complained about the naming convention by WebStorage. Although the answer of what WebStorage is and how it's used 99% of new users never read the manual nor do they ever check the manual or tutorials for some time. The WebStorage isn't working with my website is asked almost weekly.

However WebStorage is not storing data to the Web or any WebSite. The name is misleading and we have complained about its misleading name. WebStorage meaning is that the plugin uses Browser based local storing. Keep these key words in mind; LOCAL, BROWSER. WebStorage doesn't use any form of sending information up to the any website.

In essense WebStorage uses cookies.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,038

Post » Wed Mar 05, 2014 10:30 am

For offline/nodewebkit, does each exe use a different storage file thing? (so we don't need to worry about conflicting keys.)
B
151
S
75
G
20
Posts: 1,793
Reputation: 22,749

Post » Wed Mar 05, 2014 1:12 pm

@jayderyu
Thank you for clearing that up cause when I read the manual this line made me think that the app would create something where it was hosted and keep it there for later usage

'Storage per domain

The WebStorage object associates all stored data with the current domain. For example, all games running on scirra.com share the same data, but games running on facebook.com use a different set of data and cannot access any data saved from scirra.com.'


So I though as long as they was going to one place to play the game the score would be universal. WebStorage uses cookies that explains it way better. I have been trying to figure out what is the usage of the 'Dictionary' for.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Wed Mar 05, 2014 4:08 pm

@PhoenixNightly
Dictionary is a Key/Value data storage. The storage system interface is the same as WebStorage, but Dictionary is all in memory. Also the benefit of Dictionary is that you can do Dictionary.asJson and store an entire Dictionary. However Dictionary also works the same as WebStorage Session which is also temporary.

So Dictionary is great for data chunk loading and saving. I use it a lot. When you figure out how to embed a normal JSON string into a C2 Data JSON you can load single level JSON strings into C2. Very convenient.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,038

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 8 guests