Add a local_save equivalent

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Rdjrjqouqcu2
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sun Mar 26, 2023 3:33 am
Contact:

Add a local_save equivalent

Post by Rdjrjqouqcu2 »

Hi, I'm setting up a mod to auto-save the game at specific intervals to be used with the FactorioMaps Timelapse mod. (https://mods.factorio.com/mod/L0laapk3_FactorioMaps)

Currently 'game.server_save(name)' only saves the game if running on a multiplayer server.
I can use 'game.auto_save(name)' to save the game locally on demand as a workaround, but it prepends the name with '_autosave-'.

I would like to recommend adding 'game.local_save(name)' or equivalent, so that I can save the game in single player, without needing the prepended string.

Ideally, I would also like to recommend adding a 'game.local_save_copy(name)' that will preserve the currently-running save, while still saving a copy. This could also be done as 'game.local_save(name, keep_original)'.

This would allow for the following:
  • Player loads save named "Runthrough_4"
  • mod script saved "4-01"
  • Player opens save game menu and the default save game is still "Runthrough_4"
curiosity
Filter Inserter
Filter Inserter
Posts: 472
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Add a local_save equivalent

Post by curiosity »

I am surprised server_save doesn't work in singleplayer, seeing as the player is the server. I would have reported this bit as a bug.
Rdjrjqouqcu2
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sun Mar 26, 2023 3:33 am
Contact:

Re: Add a local_save equivalent

Post by Rdjrjqouqcu2 »

curiosity wrote: Sun Mar 26, 2023 5:53 am I am surprised server_save doesn't work in singleplayer, seeing as the player is the server. I would have reported this bit as a bug.
If someone confirms this is a bug, I'll be willing to create a bug report. I'm fairly certain this wouldn't make sense, because with a server and twenty logged in clients `server_save()` should only cause the server to save the game, while `local_save()` called by a mod should cause all 20 clients to save the game to their local computer, on the same tick. This should be the same as a client saving a copy of the server state without affecting other clients in a multiplayer server.

Maybe if there was a `host_save()`, which would do `server_save()` if running as a server and `local_save()` otherwise?

Also thinking about it, `local_save()` may have to be player specific, otherwise someone spamming`/c game.local_save()` on a big server can fill other player's save directory with junk. Maybe it could also pop up a confirmation, similar to the change server request I vaguely remember existing.
curiosity
Filter Inserter
Filter Inserter
Posts: 472
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Add a local_save equivalent

Post by curiosity »

Rdjrjqouqcu2 wrote: Sun Mar 26, 2023 7:00 am If someone confirms this is a bug, I'll be willing to create a bug report.
FWIW, server_save works with a non-dedicated server. It also works in a single-player multiplayer game. I would still call it a bug. Though I recall there was some case where the game determines weirdly what counts as multiplayer.
Rdjrjqouqcu2 wrote: Sun Mar 26, 2023 7:00 am I'm fairly certain this wouldn't make sense, because with a server and twenty logged in clients `server_save()` should only cause the server to save the game, while `local_save()` called by a mod should cause all 20 clients to save the game to their local computer, on the same tick. This should be the same as a client saving a copy of the server state without affecting other clients in a multiplayer server.
How does this contradict what I said?
Theis
Inserter
Inserter
Posts: 29
Joined: Tue Sep 13, 2022 9:57 am
Contact:

Re: Add a local_save equivalent

Post by Theis »

Rdjrjqouqcu2 wrote: Sun Mar 26, 2023 3:52 am I can use 'game.auto_save(name)' to save the game locally on demand as a workaround, but it prepends the name with '_autosave-'.
The autosave is also marked as an autosave, which means it can only be overwritten by another autosave-save which is annoying.

I would prefer game.server_save to work in singleplayer mode, instead of adding a local_save.
Post Reply

Return to “Modding interface requests”