energy-consumption-multiplier for a recipe

Place to get help with not working mods / modding interface.
User avatar
tiriscef
Long Handed Inserter
Long Handed Inserter
Posts: 98
Joined: Thu Mar 28, 2019 8:45 pm
Contact:

Re: energy-consumption-multiplier for a recipe

Post by tiriscef »

eradicator wrote:
Wed Jul 10, 2019 2:15 pm
Well, 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.
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.

In case someone wants to see the code: github.

Thank you all for your help.. and patience.

Post Reply

Return to “Modding help”