How do I create an autoload for game

Get help using Construct 2

Post » Tue Dec 13, 2016 9:01 am

How do I use local storage to check if game should load automatically a saved game.

1. I need this to automatically save the game after appr. every 25 minutes in order to prevent the game from crashing due to lack of memory purging. So my game saves every 1200 seconds and after save
browser: reload

in order to purge memory.

After that I would like the game to check local storage to see if there is an autosave and load it if there is.

I wonder what´s the easiest and best way to do this. I have tried to check if local storage exists but it seems not to work perfectly every time.
B
29
S
15
G
17
Posts: 137
Reputation: 10,848

Post » Tue Dec 13, 2016 10:31 am

It should though.
Check this tutorial that explains how to check for different systems if default values exists or not, and either set default values for it, or load them from the existing local storage.

Also, there is possibly something inherently wrong with your project anyway since you are talking about lack of memory purging.

You should pay more attention to your memory usage and how to lower it as much as possible.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
292
S
115
G
96
Posts: 7,295
Reputation: 70,795

Post » Tue Dec 13, 2016 10:56 am

Thanks. I will try to check out your localstorage system and see if it has something I need and understand.

About this memory usage issue. Of course I could use less memory but it does not save it from being a bug or a problem yet to be fixed as you can see yourself from these:

viewtopic.php?f=152&t=106159&p=1062642#p1062642
destroying-tiles-physics-memory-concept-abandoned_t179000
viewtopic.php?f=152&t=106159&p=786541&hilit=TOTAL_MEMORY+physics#p786541

And in fact this issue can be achieved after 2 minutes of "game designing" so in that sense there are issues that can´t be fixed by lightening the game. For example this:
viewtopic.php?f=147&t=180827

I think that this is a memory issue and it can be achieved like this:

Here is how to try if you got an error too without downloading anything:

1. Open new empty project
2. Insert sprite and paint it with some color. Don´t change it´s size (250x250)
3. Apply physics and sine behaviours to sprite. Change movement horisontal to SIZE (in sine). Don´t touch the other sine attributes.
4. Copy sprite 17 times and put them next to each other in 3 rows. 6x3 so to speak.
5. preview and wait about a minute and get an error (at least I do)

This might be a little bit offtopic since the original question is about autosave and autoload and I hope that if anybody has figured out some neat way to do it, it would be interesting to see.

Thanks again
B
29
S
15
G
17
Posts: 137
Reputation: 10,848

Post » Tue Dec 13, 2016 5:33 pm

I used localstorage to check if there was a save (localstorage value was created when game saved itself after 1200 seconds). However it did not start always (sometimes did, sometimes not). So I made it so that the player must everytime actually tap Restore game button. Because of that I think that the localstorage is not needed in this. However I wonder if there is a way to tell game that player is coming from autosave -> browser reload and not from actual start.
B
29
S
15
G
17
Posts: 137
Reputation: 10,848

Post » Tue Dec 13, 2016 6:22 pm

Global variables' values and checks on the "On start of layout" that will check "where" you are coming from, as explained in the already linked tutorial.
Same idea, same logic, only applied to your needs/program (in the tutorial is it a first execution ever, is it not; in your program is it the start of execution or not).

Also none of the links you linked to are an opened/currently investigated bug.
So if you have a case for a bug, do a proper report for it following the guidelines. Without proper opened reports, bugs won't get fixed.
Closed reports are not being investigated further. And necroing them does not help bringing attention to them either.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
292
S
115
G
96
Posts: 7,295
Reputation: 70,795

Post » Tue Dec 13, 2016 7:09 pm

Well, the browser reload function actually starts the game all over again so that´s why I think that game does not know from which direction the player is coming. I thought that after all and that´s why I think that some outside source is the answer. I wonder if persistent objects could also be an answer or a working localstorage (must learn it better)

Those links are not investigated. That´s true. Should they be? Yes. Who´s fault is it? It sounded like my fault, but I think it´s not my fault...

Btw. There.. in one of the links was a bug report so I am not making another on the same subject as the conditions are very similar and there has not been an answer to it. The memory leak is a known problem in construct 2 and making a bug report won´t change that. At least have not.

Your last answer let a little bit a bad taste to my mouth as if this is somehow me to blame or my fault. So I stop here before I write something I feel sorry afterwards.
B
29
S
15
G
17
Posts: 137
Reputation: 10,848

Post » Wed Dec 14, 2016 2:46 pm

Kyatric. You still think that I should make a bug report even though there was unanswered bug report already? You are a moderator. Is it really so that you were unaware of the memory leak problem or are you saying it does not exist?

I think you could open this up a little bit as you seemed to point a finger at my direction. I´d like you to answer since you opened the door to this kind of a discussion.
B
29
S
15
G
17
Posts: 137
Reputation: 10,848

Post » Sat Dec 17, 2016 7:14 am

Yeah. I thought so too... :)
B
29
S
15
G
17
Posts: 137
Reputation: 10,848


Return to How do I....?

Who is online

Users browsing this forum: dand, mageekm, oosyrag, Yahoo [Bot] and 27 guests