Question about the new "Local Storage" plugin

Discussion and feedback on Construct 2

Post » Wed Apr 15, 2015 10:23 am

Rable wrote:Are the local storage datas deleted if the user empties the cache of his phone, as it was the case with the webstorage?

I think it's the same as with WebStorage. Stored data and the browser cache are two different things. The cache is to store online resources locally to avoid having to request them multiple times, but if it goes missing from the cache it will request it online again. Offline data like IndexedDB is not part of that process. I think Chrome clears offline data if you also clear cookies, and Firefox has a separate "Offline website data" checkbox to clear, so I guess it depends on the browser. It's definitely not in the cache though.

Are the datas loaded in the chronological order?

Not necessarily. In theory the triggers could fire in a different order to the actions you used. If you have 150 small values which are always read and written at the same time, perhaps you could just use a Dictionary object and read and write it all as JSON data. That won't scale well for very large amounts of data though (in to the megabytes).

rexrainbow wrote:I set a value into webstorage every tick, it works fine.
But in local storage, the hard disk rotates always with big noise.

You should never do this with any storage mechanism. Other browsers might have thrashed the hard disk with the webstorage method too. Only write data when you need to!

Toddler wrote:Why can't Construct 2 handle this "On item get" trigger automatically ?

I am aware it involves more events with the new system, and I'm trying to come up with something to solve this and make it easier while preserving the async feature. See this thread: https://www.scirra.com/forum/idea-make-async-easier-with-quot-then-quot-event_t128870

"Oooo with the new *parallel* processing, things will be faster" and all that crap.

Well, lots of other users wonder why C2 doesn't have more parallel features that can make use of multiple cores to improve performance. Jank (small pauses during games) is also a big problem for a lot of people. This new async storage plugin allows for parallel processing and reduced jank. If you don't like that then I don't know what we can do, we just can't win, someone will always be unhappy either way!

You can of course just keep using WebStorage for existing projects. You are not *required* to update, we just suggest that it is a good idea if you can. If you have hundreds of values and a huge project depending on complex usage of WebStorage, maybe you could just leave it, and use Local Storage for your next project. The decision is up to you, but transitioning to Local Storage is simply recommended, not mandatory.
Scirra Founder
B
381
S
222
G
84
Posts: 23,975
Reputation: 189,160

Post » Wed Apr 15, 2015 11:42 am

@Toddler while it would make sense to have trigger for everything asynchronous, I will admit that it can become a huge bother, and being able to stay in the realm of synchronous events would be nice when asynch is not needed and will be bothersome to implement.

Or rather, finding a cleaver way to make those asynchronous events work would be a benediction, for now we just have AJAX, and saves, and now local storage, and yet people stuggles when dealing with that, sure a trigger is the current way of doing it, and it is not a real issue with storage (as saving datas should be something done at one specific point rather than constently in game) but as more and more feature would go that way, it will become unusable pretty quickly.

Async storage is not the problem, Async events are in general tricky to use, as they go against the spirit of the event system. And we cannot just say "No" to those, as they can be pretty useful, so a solution has to be found.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
44
S
18
G
18
Posts: 2,108
Reputation: 16,465

Post » Wed Apr 15, 2015 6:05 pm

Agree, which I *hope* will be implemented, maybe the load event can have the option to wait until the trigger happen, get that data from the returned trigger and assign it to the variable so that at the front end, it behaves JUST LIKE the good old friendly webstorage.

Or else, we will soon have to say good bye to really simple one line codes like this:
Image

For this *new* & *improved* method that do in multiple lines, what can be done in one line in the past, YEAH UPGRADE !
Who needs a cell phone when you have cups and strings !
Let's rub two woods together to make fire, it's *better* because it takes more effort !
B
12
S
3
Posts: 284
Reputation: 1,686

Post » Wed Apr 15, 2015 9:22 pm

It's true that this new system is definitely overall harder to work with. However, maybe what we should be asking is, are our current Webstorage practices bad? I currently use Webstorage as a replacement for variables all over the place, and very often set its values every tick. Maybe that's acually in general bad practice? Disk I/O is expensive after all (afaik), and (maybe?) won't show up in CPU usage tables.

Could just be another case of C2 making something 'too' easy.

I think the manual could do with a lot more written on 'best practices'. It could alleviate a lot of confusion at times like this.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,644

Post » Wed Apr 15, 2015 10:21 pm

sqiddster wrote:It's true that this new system is definitely overall harder to work with. However, maybe what we should be asking is, are our current Webstorage practices bad? I currently use Webstorage as a replacement for variables all over the place, and very often set its values every tick. Maybe that's acually in general bad practice? Disk I/O is expensive after all (afaik), and (maybe?) won't show up in CPU usage tables.

Could just be another case of C2 making something 'too' easy.

I think the manual could do with a lot more written on 'best practices'. It could alleviate a lot of confusion at times like this.


Indeed saving the datas in other places than memory is something you normally do on specific occasions, not on a current basis, here are some exemples:

-save points in many early games
-pause screen with a save option in most PC games (the user chooses when to actually save, and so, no need to save constantly)
-automatic save of data between level transitions
-in game and watch gallery, the game would actually save when pausing the game, so if the player quits it, when turning the power on again, it will remuse the gameplay.
-etc..

All in all, treating a save (and this local storage one Particularly) like a non-local save seems to actually be the way to handle it: when you save data over to a server, you cannot think it will be back instantly, this seems to work in a similar way, perhaps having this in mind may be easier, having the lowest number of data to save, and knowing when it is a necessity to actually save them or retrieve them, the same way you would do if they were on a distant server.

At least this is how it seems to work.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
44
S
18
G
18
Posts: 2,108
Reputation: 16,465

Post » Wed Apr 15, 2015 11:55 pm

@Toddler
@sqiddster
@Aphrodite

I had made a "cache" plugin of local storage. Does it look better?
B
107
S
25
G
229
Posts: 4,349
Reputation: 130,384

Post » Thu Apr 16, 2015 3:21 am

You know it's bad when an "upgrade" is so awesome, users need to make plugins to *fix* it.
Thank you for your effort rexrainbow.
B
12
S
3
Posts: 284
Reputation: 1,686

Post » Thu Apr 16, 2015 3:28 am

@Toddler

You are welcome.
My team member also needs it, he does not like the async - reading, either.
B
107
S
25
G
229
Posts: 4,349
Reputation: 130,384

Post » Thu Apr 16, 2015 4:34 am

sqiddster wrote: I currently use Webstorage as a replacement for variables all over the place, and very often set its values every tick.


Even minecraft waits 120 ticks before writing to disk... why would you need to write values to disk every tick? Doesn't Airscape use check points? Or are you trying to save the exact position when the user quits or crashes? Not sure I understand the benefit to replace variables.. does it free up memory or something? that constant fileI/O must create a huge performance drain...
B
80
S
27
G
14
Posts: 1,108
Reputation: 14,492

Post » Thu Apr 16, 2015 5:24 am

I realized today that there is nothing wrong with the way the new storage is.

Just use Dictionary for your data. When you want to save long term use the new LocalStorage. When loading use a splash screen and when it's loaded from local storage into dictionary your all good. Honestly this is how I do saving loading in Java/C++/Unity anyways.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,013

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: Colludium, radbrothers and 9 guests