Page 1 of 1

Event: on_pre_save - to interact before a save state is finalized

Posted: Sun Feb 05, 2023 7:09 am
by Theis
TL;DR
Give mods the option to manipulate LUA::global before a Save
The opposite of on_load.
What ?
Fire an event either on:
  1. on_save
  2. on_pre_save
Where mods gets a chance to prepare the save state in some way.
With the potential event-data:
  • player_index::uint? - if saved for one player, the index of that player
  • name::defines.events -Identifier of the event
  • tick::uint - Tick the event was generated.
  • is_server_save::boolean
  • is_auto_save::boolean
  • save_name::string - The name of the new save or the name of currently-running save, where the game is saved to.
Why ?
This has at least 2 uses: It allows mods to prepare the game for a save; It allows mods to prepare themselves for save-state.

Preparing the game for a save could be interesting for modders, if they for instance wanted to punish people that saved frequently by making the biters more aggressive.

Preparing the mod for the save-state, means that mods can use LUA::local variables throughout and only store/load LUA::global when an event is fired. Since then both on_save & on_load would be covered.

Re: Event: on_pre_save - to interact before a save state is finalized

Posted: Sun Feb 05, 2023 8:40 am
by boskid
No. 104337