[Solved]How can I save just a variable?

Get help using Construct 2

Post » Tue May 27, 2014 5:44 am

I want to save a variable to the player's pc or mobile... no just a cookie. I know the simple save/load actions do it, but i think it don't work just for a variable, right?
Last edited by Zathan on Tue May 27, 2014 7:13 am, edited 1 time in total.
B
20
S
4
Posts: 387
Reputation: 2,274

Post » Tue May 27, 2014 6:06 am

B
56
S
15
G
13
Posts: 826
Reputation: 17,675

Post » Tue May 27, 2014 6:20 am

Tekniko wrote:https://www.scirra.com/manual/120/webstorage

Thanks for the answer :)
But, using the webstorage, if the user clear the internet cache, the savegame will be lost, right?
B
20
S
4
Posts: 387
Reputation: 2,274

Post » Tue May 27, 2014 6:39 am

@Zathan The suggested manual by Tekniko answers your question. You can find it in the third paragraph.
Take your time to read the entire manual ;)
It's time for me to return the favor :)
B
32
S
9
G
9
Posts: 132
Reputation: 5,370

Post » Tue May 27, 2014 6:56 am

ikke2902 wrote:@Zathan The suggested manual by Tekniko answers your question. You can find it in the third paragraph.
Take your time to read the entire manual ;)

Yes, it's written that is not deleted...
But in the "Local vs. Session storage" part, it's written that you have two options. But in both, when the cache is cleaned, everything is lost... did I miss something?

Sorry... my english is not good, so... ;)
B
20
S
4
Posts: 387
Reputation: 2,274

Post » Tue May 27, 2014 7:03 am

@Zathan
Manual says...
Local vs. Session storage
The WebStorage object allows data to be stored in two places: Local storage and Session storage.

Local storage is permanent (until the user clears their cache). If the user comes back the next day, local storage still has the saved data.

Session storage only lasts with the current browser session. If the user comes back the next day, session storage is empty again.


Cache is not cookies, big difference. Cache is wiping all browser data, basically making the browser start from scratch.
You cannot install something on a users computer that he/she doesn't have the ability to delete.
If you want permanent data that user can not delete, then you must store data in external server and connect the game to that server to retrieve that data.

Webstorage is your best/easiest option. And local is permanent, and session is only lasts till user closes his browser.
The save/load also stores an array entry into webstorage.
If the user wipes his cache, then he wipes your saved game data, but also all data from all websites and he obviously wants to do that, which he is allowed to do - its his machine.

Off topic Sidenote: Interesting fact, also no website can tell you your driver is outdated. So those websites that say there is a new windows driver - its a lie. Remember, users pc is belongs to him, its like his house, he chooses who he invites in to see what he has got, and also what those people leave behind, and of course what he wants to keep.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Tue May 27, 2014 7:11 am

DUTOIT wrote:@Zathan
Manual says...
Local vs. Session storage
The WebStorage object allows data to be stored in two places: Local storage and Session storage.

Local storage is permanent (until the user clears their cache). If the user comes back the next day, local storage still has the saved data.

Session storage only lasts with the current browser session. If the user comes back the next day, session storage is empty again.


Cache is not cookies, big difference. Cache is wiping all browser data, basically making the browser start from scratch.
You cannot install something on a users computer that he/she doesn't have the ability to delete.
If you want permanent data that user can not delete, then you must store data in external server and connect the game to that server to retrieve that data.

Webstorage is your best/easiest option. And local is permanent, and session is only lasts till user closes his browser.
The save/load also stores an array entry into webstorage.
If the user wipes his cache, then he wipes your saved game data, but also all data from all websites and he obviously wants to do that, which he is allowed to do - its his machine.

Ah, great explanation! Now is clear to me. :D
Thank you.
B
20
S
4
Posts: 387
Reputation: 2,274


Return to How do I....?

Who is online

Users browsing this forum: 8tomo8, brunopalermo and 10 guests