Page 1 of 1

Changing transport belt speed in-game

Posted: Wed Aug 31, 2022 8:41 pm
by xenon54xenon
Decided to do some poking around in the api docs, and it seems like the transport belt prototype(s) have their speed set before runtime. Problem is, I would like to change the speed of transport belts while the map is loaded, preferably with circuit signals, and even have multiple different belts running at their own speeds. I'd appreciate it if somebody could help me figure out if this is possible to implement within the vanilla prototypes, whether I can change the prototypes to make this possible, if it would take a top-bottom reimplementation of belt logic and prototypes, or if the only possible solution is to preload like a hundred different transport belts of different speeds and script different ones to swap in when the speed changes it's impossible.

Re: Changing transport belt speed in-game

Posted: Wed Aug 31, 2022 9:24 pm
by boskid
There is no support for this. This falls into the common problem of deciding what value to take in case of a prototype data changes: should it take a value from an existing entity or a value from a new prototype? Internally TransportLines can have speed changed and it is used in one specific case (when a transport belt is connected with a circuit wire and it is disabled, the speed is forced to 0) but there is no place where a speed value is save-loaded, its always taken from the prototype and all the changes are reapplied from the control behavior state. There are also some tiny things to consider like splitting and merging transport lines when belts would have the same speed while being of different prototype or would have different speed when being of the same prototype: for example transport belt with control behavior will never merge transport lines to adjacent connectables because splitting a transport line every time a circuit condition is changed would be way too expensive.

I think this would also create a lot of issues with the belt animations

Re: Changing transport belt speed in-game

Posted: Wed Aug 31, 2022 10:55 pm
by xenon54xenon
How much would need to be reimplemented? Like is this a problem going back to the entity prototype itself or would it 'only' need transport belts (and presumably their logic) to be remade?