Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / how to save game progress correctly HTML5.

Author
Message
pavel_sv_1982
11
Years of Service
User Offline
Joined: 9th Apr 2013
Location: Russia
Posted: 17th Jun 2024 15:12 Edited at: 17th Jun 2024 15:49
Hello. Please tell me how to properly save and load the progress of a game compiled in HTML5? So I launched the game, played, exited, closed the game window. The next day I went into the game and wanted to load the old save of the game. But an error pops up.

you need to use the recording format:
- "user://savegame/save.sav"?
programming is a hobby, not a job.
P.S. in google and youtube - nikename pavelman- it is not me!
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 17th Jun 2024 19:11 Edited at: 17th Jun 2024 19:14
i use SharedVariables/Cookies in HTML while i generally have only a small amount of data to save.

you could build and save a a single string to hold various data to keep things tidy vs multiple cookies (or not).

and, if you do go this route and plan to host the game on itch.io or the like which uses cross-site cookies, be sure to modify the player to accomodate.

meanwhile, there are other options. see the top of this post
pavel_sv_1982
11
Years of Service
User Offline
Joined: 9th Apr 2013
Location: Russia
Posted: 18th Jun 2024 12:11 Edited at: 18th Jun 2024 19:11
thank you very much.

Virtual Nomad
Quote: "i use SharedVariables/Cookies in HTML while i generally have only a small amount of data to save."


How many variables can I store in this word?

it turns out that I should moderate my Napoleonic appetites, and save only the intermediate process between missions? Well, for example, what task am I on now?
programming is a hobby, not a job.
P.S. in google and youtube - nikename pavelman- it is not me!
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 18th Jun 2024 19:26 Edited at: 18th Jun 2024 19:35
AFAIK, cookies are generally limited to 4096 bytes with a single character = 1-2 bytes each and browsers can limit the # of cookies per domain, so...
i dont store much myself and never had an issue with size but i'm quite novice to much more than the above understanding other than it's always best practice to maximize efficiency, in general.
Quote: "How many variables "

well, that depends on how you store them. do you need them to fully read "armor=10|damage=5|..." inside? or can you condense to "ar=10|dg=5|..." or, if you stay consistent throughout re: the order you read/write, "10|5|..." would be the most efficient. you get the idea.

you haven't mentioned how many items you're trying to save/load but your concern on size limits makes me think you have tons so there may be a better way than cookies (which would venture into unknown realms for me that others would have better insight on).
pavel_sv_1982
11
Years of Service
User Offline
Joined: 9th Apr 2013
Location: Russia
Posted: 19th Jun 2024 07:10
Virtual Nomad
Quote: "AFAIK, cookies are generally limited to 4096 bytes with a single character = 1-2 bytes each and browsers can limit the # of cookies per domain, so...
i dont store much myself and never had an issue with size but i'm quite novice to much more than the above understanding other than it's always best practice to maximize efficiency, in general."

So about 4096 bytes?
Thank you. Now I understand how to make a game.
I was going to store the following information: card number, a little about the amount of a certain arsenal (what and how much ground equipment, what and how much air equipment, how many and what weapons) Before each mission, the player chooses who will go and with what weapons. Then store which mission is completed. although there will be no memory of completed missions. Missions can be replayed several times and receive rewards. Arsenal is running out. the arsenal has run out, you've lost, or go alone, but even here the number of personal machines is limited.
programming is a hobby, not a job.
P.S. in google and youtube - nikename pavelman- it is not me!

Login to post a reply

Server time is: 2024-11-07 04:42:34
Your offset time is: 2024-11-07 04:42:34