Get autosave settings?

Place to get help with not working mods / modding interface.
Post Reply
hoylemd
Inserter
Inserter
Posts: 27
Joined: Tue Apr 17, 2018 2:14 am
Contact:

Get autosave settings?

Post 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.
Last edited by hoylemd on Thu Apr 20, 2023 9:38 pm, edited 1 time in total.

BicycleEater
Fast Inserter
Fast Inserter
Posts: 153
Joined: Sun Jul 26, 2020 4:05 pm
Contact:

Re: Get autosave settings?

Post 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.

hoylemd
Inserter
Inserter
Posts: 27
Joined: Tue Apr 17, 2018 2:14 am
Contact:

Re: Get autosave settings?

Post 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

hoylemd
Inserter
Inserter
Posts: 27
Joined: Tue Apr 17, 2018 2:14 am
Contact:

Re: Get autosave settings?

Post 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?

BicycleEater
Fast Inserter
Fast Inserter
Posts: 153
Joined: Sun Jul 26, 2020 4:05 pm
Contact:

Re: Get autosave settings?

Post 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...

hoylemd
Inserter
Inserter
Posts: 27
Joined: Tue Apr 17, 2018 2:14 am
Contact:

Re: Get autosave settings?

Post by hoylemd »


hoylemd
Inserter
Inserter
Posts: 27
Joined: Tue Apr 17, 2018 2:14 am
Contact:

Re: Get autosave settings?

Post 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!

Post Reply

Return to “Modding help”