Page 1 of 1

Efficient circuit network processing

Posted: Wed Jun 19, 2024 12:05 am
by scruffyvoltherder
TL;DR
A special type of circuit network entity with behavior to allow the mod to take part in circuit network processing.
What ?
The entity, Modded_Circuit_Point, would connect similarly to an Inserter, being able to take input and send output from the same connection. During Circuit Network processing, the game calls a function , Process_Modded_Circuits(), with a list of any Modded_Circuit_Point entities where the input signal has changed.
Each mod only processes the modded_circuit_points that it creates. The code inside Process_Modded_Circuits() would then be able to set Modded_Circuit_Point output signals or store data in global for use in on_tick() or other events.

I don't think that this would affect validation as long as nothing that changes the game state (other than setting Modded_Circuit_Point outputs) is done from Process_Modded_circuits(). If the mod did need to do anything that would require validation, it could just leave some data in global to be processed later.


Why ?
Some mods may want to react to circuit network changes. Currently, mods can only do this by polling the connected circuit network of an entity. This introduces a huge trade-off. A mod can poll infrequently, but will miss pulsed signals. Or, A mod can poll every tick, but that would introduce a massive UPS penalty. Calling into mod Lua code during circuit network processing will allow mods to interact with the circuit network in a fast, efficient way without having to miss fast or pulsed signals.