[Documentation] Page about event call order.

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 3250
Joined: Tue Jul 12, 2016 9:03 am
Contact:

[Documentation] Page about event call order.

Post by eradicator » Sat Jul 14, 2018 3:25 pm

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 :).
Author of: Hand Crank Generator, Screenshot Hotkey 2.0
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Rseding91
Factorio Staff
Factorio Staff
Posts: 9672
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [Documentation] Page about event call order.

Post by Rseding91 » Sat Jul 14, 2018 11:42 pm

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.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2149
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [Documentation] Page about event call order.

Post by Optera » Sun Jul 15, 2018 6:25 am

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?

Rseding91
Factorio Staff
Factorio Staff
Posts: 9672
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [Documentation] Page about event call order.

Post by Rseding91 » Sun Jul 15, 2018 10:49 am

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?
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).
If you want to get ahold of me I'm almost always on Discord.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 3250
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [Documentation] Page about event call order.

Post by eradicator » Mon Jul 16, 2018 5:06 pm

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.
Arg, yes. Most events can occur multiple times ofc.

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: Hand Crank Generator, Screenshot Hotkey 2.0
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding interface requests”

Who is online

Users browsing this forum: Deadlock989