Add LuaSurface.time_factor please

Things that we aren't going to implement
Post Reply
mrvn
Smart Inserter
Smart Inserter
Posts: 5709
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Add LuaSurface.time_factor please

Post by mrvn »

TL;DR
Add an option run surfaces at different speeds.
What ?
The /editor has an interface to speed up or slow down the game, to pause it, to single step it or to run it for a given number of ticks. I want the same thing but localized to a surface.

Add a float LuaSurface.time_factor that determines how fast time passes on a surface. Setting surface.time_factor = 0.5 would mean that on this surface one tick is computed only every other ticks of the game. Setting surface.time_factor = 2 would mean the game computes two ticks on this surface for every tick passing elsewhere.

Setting surface.time_factor = 0 would pause everything on the surface. Items would stop moving on belts, inserters stop mid swing. All entity updates would pause.

And last setting surface.time_factor = -42 would advance the surface for 42 ticks, incrementing the time_factor every tick till it hits 0 and pauses.

This would allow mods to implement the same speed controls the edit has in a localized way.
Why ?
Playing with for example the https://mods.factorio.com/mod/BlueprintLab_design is great. You can design your blueprints and keep templates of them around that can be easily and quickly edited when you think of changes.

But every thing you place in the Blueprint Lab costs UPS. If you use infinity pipes or chests to test blueprints then everything still consumes and produces items all the times. But 99.9% of the time there is no interest in the templates construction running. If you don't then there is still a lot of entity updates hapening. That's just wasted CPU time. So it would be great to automatically pause the Blueprint Lab surface whenever the player leaves.

It would also be great to have speed controls while the player is inside the lab (which the mod would provide, not a request for the game to add them) so one can pause everything while redesigning. There is no point to it and in fact it's often a hindrance to work on belts that have items moving on it. Or to single step through a combinator construction to debug problems. I realize this can be done with /editor, but not in a multiplayer game as it would ruin the fun for all other players. Having the effect be localized to just one surface would allow using it in multiplayer games too. Some players could debug the combinators together inside the lab while others keep playing normal on the main surface.

For other blueprint editing mods pausing the surface would allow keeping even huge blueprint libraries in that space instead of having to recreate the entities every time a player enters and destroying them when the player leaves. Or a more lazy approach can be used to create/destroy editing surfaces allowing mods to cache the most recently edited blueprints at least for a while.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2250
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Add LuaSurface.time_factor please

Post by boskid »

This is way outside of what the engine is capable of doing and way off of how stuff works. For example belts are not updated per-surface, TransportLineManager is completly unaware of where the transport lines are (that is why linked-belt was relatively easy to implement). All the belts animations are using entity tick which is a shared variable for the entire game, they are not per-surface. Electric networks are also unaware of surfaces they are on, if you have a script connected power poles on separate surfaces then they are also updated on a tick-by-tick base and having 2 surfaces with different time speed is way outside of what could be done.

Wont happen.

Post Reply

Return to “Won't implement”