WebStorage VS Local Storage

Discussion and feedback on Construct 2

Post » Fri Apr 24, 2015 1:31 am

sqiddster wrote:@alspal it's an absolute lifesaver when you need to move to a save slots system. All of the webstorage references in Airscape are function calls that pulls the data from the current save slot.


I usually just have a global variable called something similar to "ProfileName" or "SaveSlot", and then if I need a variable (like the HP) from that profile slot I'd just get the value from the key called: ProfileName & "health"

So I still don't understand the purpose of functions, thanks for answering though! Image
B
151
S
75
G
20
Posts: 1,793
Reputation: 22,749

Post » Fri Apr 24, 2015 5:16 am

@alspal

The reason functions are good here is because you know for a fact that you'll never have to go to every instance of a call and change it. For example, say you didn't want "SaveSlot" to be a global variable anymore, but a Webstorage/LocalStorage value. You'd simply have to change one reference in the function, and that's that.

There are a lot of other reasons functions are cool, but the best way to realize how useful they are is to try and use them!
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,699

Post » Fri Apr 24, 2015 6:15 pm

@ashley the data I store in WebStorage is only from arrays, so I'm thinking of a way to migrate.
When the game start load array data from webstorage and then destroy localkey and save data to Local Storage.
Next time when game start again - if localkey does not exist look and load data from Local Storage.

That this sounds about right?

@alspal functions are best used especially when you have parameters, so you can replace the value of an parameter with a variable. (any variable; sprite, text, global variable, local variable ...) Also, if you have a group of actions that get repeated through out your project, functions are the best way to go about.
What I like to do is have an Event Sheet called "functions" that I import into all the other Event Sheets of my project.
Last edited by cristiart on Sat Apr 25, 2015 1:25 am, edited 2 times in total.
B
37
S
9
Posts: 63
Reputation: 2,255

Post » Fri Apr 24, 2015 9:00 pm

cristiart wrote:@ashley the data I store in WebStorage if only from arrays, so I'm thinking of a way to migrate.
When the game start load array data from webstorage and then destroy localkey and save data to Local Storage.
Next time when game start again - if localkey does not exist look and load data from Local Storage.

That this sounds about right?



great idea
B
46
S
16
G
8
Posts: 794
Reputation: 8,335

Post » Fri Apr 24, 2015 9:02 pm

what are local storage actions instead of webstorage ?? (replacement ) for the

if Local Key "......" exists >>>>> set variable to webstorage.LocalValue('......')
and
set LocalKey ".........." to variable????

thanks ?
B
46
S
16
G
8
Posts: 794
Reputation: 8,335

Post » Sat Apr 25, 2015 1:14 am

@matrixreal
to save into LocalStorage use action >>> LocalStorage Set item "yourname" to Array.AsJSON

to load from it:
- on start of layout >>> LocalStorage check item "yourname" exist (***important to check storage first)
- LocalStorage On item "yourname" exist >>> Array load from Json string LocalStorage.ItemValue
B
37
S
9
Posts: 63
Reputation: 2,255

Post » Sat Apr 25, 2015 1:39 am

cristiart wrote:@matrixreal
to save into LocalStorage use action >>> LocalStorage Set item "yourname" to Array.AsJSON

to load from it:
- on start of layout >>> LocalStorage check item "yourname" exist (***important to check storage first)
- LocalStorage On item "yourname" exist >>> Array load from Json string LocalStorage.ItemValue


thanks a lot thats perfect i don't see any huge difference bt if ashley say that is better than webstorage so i will use localsorage :)

and you know the difference between synchronised and asynchronised save ?
B
46
S
16
G
8
Posts: 794
Reputation: 8,335

Post » Mon May 25, 2015 3:14 am

Is there a place in the manual or forums that gives a descriptions and shows the full use of Local Storage? I remember reading the release notes of how it was replacing WebStorage, but I still see WebStorage in the manual with no mention of Local Storage? Any assistance would be appreciated. Thanks.
B
42
S
16
G
3
Posts: 169
Reputation: 4,383

Post » Mon May 25, 2015 3:24 am

@CDogs1964 I believe that the manual will be updated whit the next stable release
B
92
S
30
G
11
Posts: 654
Reputation: 11,707

Post » Wed May 27, 2015 8:38 pm

Deleted - posted in wrong place :-(
Last edited by oldandgrey on Wed May 27, 2015 9:11 pm, edited 2 times in total.
B
13
S
2
G
1
Posts: 22
Reputation: 760

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 15 guests