Skip to content
Matthew edited this page Feb 19, 2019 · 7 revisions

The data lifecycle determines what we can and cannot do in scenario code.

Required reading: https://lua-api.factorio.com/latest/Data-Lifecycle.html

With factorio data lifecycle in mind, this is how we define the lifecycle in RedMew:

_LIFECYCLE
1 (The settings stage)
2 (The data stage)
3 (Migrations)
4 The control stage (control.lua initialization)
-- LocalisedString become available after stage 4
5 On_init (control.lua init/loaded)(`game` is available in this stage)
6 On_load (control.lua init/loaded)(`game` is not available in this stage)
-- `game` is available in all stages below
7 (control.lua script.on_configuration_changed)
-- players can join here
8 Runtime (control.lua runtime)

Scenario code has no access to 1-3 and no use for 7. They are documented for the sake of completion.
We mark the stages we do have access to in order to determine what can/can't be run and lock out functions that would cause errors or desyncs.

Examples

A runtime-only function requires _LIFECYCLE == _STAGE.runtime
A module that is available pre-runtime requires _LIFECYCLE < _STAGE.runtime

Clone this wiki locally