Page 1 of 1

Get autosave settings?

Posted: Thu Apr 20, 2023 6:43 pm
by hoylemd
Hi folks,

(actual question underlined if you want to skip the context)

I have an idea for a small mod I want to implement: an autosave warning system. I like the autosave system, but it often happens at an inopportune time. One thing I like about Satisfactory is that it gives you a bit of a warning when autosave is about to happen, and I found that really helpful to avoid being annoyed by the sudden pause.

My ideal dreamland concept would be a mod you install and it all just works - it knows the current interval, and knows the time since the last autosave, and can therefore accurately compute when the next one will happen, and give you a 1 minute, 30s, 10s, 5,4,3,2,1 countdown (for example, maybe even configurable). But I don't expect that will be completely possible.

So my MVP would be for it to be entirely manually configured: Basically theres a ui (maybe in mod settings?) where you input how often you want the warnings (and what warnings you want), and it's up to the player to ensure that matches up with their actual autosave settings. Then the actual warning timing can be based on `game.tick`. I'll Probably implement that soon.

Which brings me to my actual question. Once I have the MVP done, I'd like to automate it! Is there any way to get the autosave interval of the current map? I looked through the docs and I couldnt find an obvious way to get it, but I might have just missed it.

I also realize this wouldn't really work based on `game.tick` alone if the autosave interval changes (unless autosave is implemented in a strict `game.autosave when game.tick % interval == 0` way, but I'm going to assume I'm not that lucky :P) . If there's *also* a way to determine the tick of the most recent autosave, that'd pretty much solve it all, but again, not going to get my hopes up. I did see that I could just override the entire autosave system, https://mods.factorio.com/mod/ixuAutoSave (which would make this all trivial), but I want to avoid that if I can.

Re: Get autosave settings?

Posted: Thu Apr 20, 2023 7:56 pm
by BicycleEater
I don't know about anything else, but I just tested it and it seems like the autosave happens exactly when game.tick % interval == 0, though that was only a short test - to do it yourself, start up a creative save, and run the command `/c game.speed = 100`, and then change the autosave interval and see when it autosaves.

Re: Get autosave settings?

Posted: Thu Apr 20, 2023 9:39 pm
by hoylemd
Yeah, I'll see if the interval is a simple modulo or more of a counter since the last one. If thats the case then I just need to get the autosave interval

Re: Get autosave settings?

Posted: Fri Apr 21, 2023 2:00 pm
by hoylemd
Just confirmed, autosave interval behaviour is a simple 'save at time played % autosave interval == 0`.

My method, for posterity:

0) start creative mode game
1) as suggested above, `/c game.time = 100`
2) observe a couple 5-minute (default) autosaves (so most recent autosave is at 15:00)
3) `/c game.time = 5` (so next step doesnt go crazy)
4) set autosave interval to 1 minute
5) observe 2 autosaves (so most recent is at 17:00)
6) set autosave interval back to 5 minutes
7) `/c game.time = 100`
8) observe one autosave, and check 'time played' in `load game` list

Most recent autosave 'time played' is 20:00. If it were a 'time since last autosave', then the newest one would be at 22:00, since that's 5 minutes after the previous one at 17:00. The last autosave being at 20:00 refutes that, so we can conclude that autosave is indeed implemented with a simple modulo. :geek:

So that means all I need to be able to make this completely automated is a way to check what the autosave interval is. Is that possible or am I stuck with manually setting it for now?

Re: Get autosave settings?

Posted: Fri Apr 21, 2023 3:29 pm
by BicycleEater
I'm pretty sure you can't get that info - maybe put in a modding interface request, as it seems reasonable to want to know it...

Re: Get autosave settings?

Posted: Sat Apr 22, 2023 2:09 pm
by hoylemd

Re: Get autosave settings?

Posted: Mon Apr 24, 2023 6:43 pm
by hoylemd
I've published a first version of the mod here: https://mods.factorio.com/mod/autosave-alert

Hopefully the native setting can get exposed through the API soon and it can be completey automated!