Yes, this solution works like a charm. With 50 checks every 10 ticks the script takes min 0.040ms and max 0.072ms regardless of factory size. I think that's... justifiable.eradicator wrote: ↑Wed Jul 10, 2019 2:15 pmWell, if it's only for a subset of machines, and you don't care about the player losing (or gaining) a bit of energy/stuff, then updating beacons in a fixed-time manner should be ok. Fixed-time means that you process only i.e. 50 beacons once per second. That way the scale of the factory only influences the update delay, and not the processing cost, keeping your mod viable for large factories. This is what for example mods like "Bottleneck" do.
Edit: If you hook into some events like gui_closed to detect the recipe change and only use the on_tick as a backup in case you missed some recipe change (because perfect detection would be difficult), then you could use a much larger delay in on_tick.
In case someone wants to see the code: github.
Thank you all for your help.. and patience.