I have a scenario where Mod A has a global Table, and Mod B wants to read items from Mod A's table with a remote interface and add new ones based on what it finds.
Mod A's on_configuration_change handler:
1 Check if Table exists.
2 If not, create Table and add default entries.
Mod B's on_configuration_change handler:
1 Read Table[item1] using Mod A's interface
2 Insert Table[item2] using Mod A's interface
I'm getting an error because when Mod A's on_configuration_changed event runs after Mod B's, Table[item1] might not exist. If it can't be read, then Table[item2] will never be written, and that will cause problems down the road even if I prevent Mod B from crashing by checking for nil.
It seems like adding Mod A as a dependency for Mod B fixes the problem. Is this the correct solution, or is it a coincidence and I should look for a better way?
Order in which on_configuration_change events are processed?
Order in which on_configuration_change events are processed?
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Re: Order in which on_configuration_change events are processed?
Think I answered my own question. Very first line of the Data Lifecycle page says
That implies the same sort order is applied at every point where arbitration between mods is required, including on_configuration_change and other event handlers that might have more than one mod subscribed to them.Factorio sorts mods first by dependencies then by natural sort order accounting for case
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
