What?
The documentation doesn't seem to have a page about the order in which events are called in correlation to each other. Specifically things like:
"Is on_chunk_generated called after on_nth_tick"? (discussed here)
"Is on_tick called before on_nth_tick?" etc.
This: https://lua-api.factorio.com/latest/def ... nes.events list seems oddly un-alphabetical, so i'm not sure if that is the order. A dedicated page would be nice to have :).
[Documentation] Page about event call order.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
[Documentation] Page about event call order.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: [Documentation] Page about event call order.
on_tick is run before on_nth_tick and on_chunk_generated is run after on_tick.
The order of other events isn't defined. For example: robot built entity can happen any time during a tick any number of times along with robot-mined-entity any time during a tick any number of times.
The order of other events isn't defined. For example: robot built entity can happen any time during a tick any number of times along with robot-mined-entity any time during a tick any number of times.
If you want to get ahold of me I'm almost always on Discord.
Re: [Documentation] Page about event call order.
What about event handling results between mods?
Say mod 1 handles on_built_entity(mod1_entity) by deleting mod1_entity and replacing it with a different entity.
Will mods loaded after mod 1 also get on_built_entity(mod1_entity) with mod1_entity.valid = false?
Say mod 1 handles on_built_entity(mod1_entity) by deleting mod1_entity and replacing it with a different entity.
Will mods loaded after mod 1 also get on_built_entity(mod1_entity) with mod1_entity.valid = false?
My Mods: mods.factorio.com
Re: [Documentation] Page about event call order.
No, in that case the event calls simply stop because an invalid entity is invalid and can't even be compared to another entity in any meaningful way (like trying to check if a collection of nils is a specific nil).Optera wrote:What about event handling results between mods?
Say mod 1 handles on_built_entity(mod1_entity) by deleting mod1_entity and replacing it with a different entity.
Will mods loaded after mod 1 also get on_built_entity(mod1_entity) with mod1_entity.valid = false?
If you want to get ahold of me I'm almost always on Discord.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: [Documentation] Page about event call order.
Arg, yes. Most events can occur multiple times ofc.Rseding91 wrote:on_tick is run before on_nth_tick and on_chunk_generated is run after on_tick.
The order of other events isn't defined. For example: robot built entity can happen any time during a tick any number of times along with robot-mined-entity any time during a tick any number of times.
Are on_tick and on_nth_tick at least always guaranteed to be the first two events in each tick? (Could they be script.raise_event'ed to break that assumption?)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.