Add a disable_connections flag to create_entity for rolling stock types to disable autoconnecting to other rolling stock

BurninSun
Long Handed Inserter
Long Handed Inserter
Posts: 93
Joined: Fri Mar 16, 2018 4:54 am
Contact:

Add a disable_connections flag to create_entity for rolling stock types to disable autoconnecting to other rolling stock

Post by BurninSun »

My request is for LuaSurface::create_entity when used with any of the rolling stock types to add an optional disable_connections flag. Setting this flag to true would cause the created rolling stock to not auto connect to other rolling stock.

I'm trying to script create trains at a specific location, but I do not want them to auto connect to adjacent trains if within connection range. Specifically, I am calling .clone on a rolling stock entity and placing it at another location. LuaEntity::clone doesn't have entity type specific parameters so I do not expect support there. My idea is to use create_entity to create a minimally sized cargo wagon with its connections disabled at the front of where the cloned train should be, let the cloned rolling stock connect to that, then destroy the cargo wagon. I found what I thought was a way to accomplish this through blueprints with their .stock_connections property to force a blueprinted, minimal sized cargo wagon to not connect to nearby rolling stock, but a separate issue (viewtopic.php?t=133587) makes using this unreliable.

Cloning then disconnecting the rolling stock doesn't work as upon cloning the existing trains schedule, manual mode and speed gets modified in a way that is unrecoverable from events.

Cloning then moving the rolling stock into place is difficult as it cannot be teleported directly. At best, it would need to have a complexly calculated speed set then wait a tick for it to move.

Using create_entity directly runs into all of the same issues and would still need API support to disable auto connections.
Amarula
Filter Inserter
Filter Inserter
Posts: 688
Joined: Fri Apr 27, 2018 1:29 pm
Contact:

Re: Add a disable_connections flag to create_entity for rolling stock types to disable autoconnecting to other rolling s

Post by Amarula »

Would be great if this was an option when placing a blueprint of a train. First train works great, print down second following train and instead of two distinct trains I get one messed up joined train.
My own personal Factorio super-power - running out of power.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4551
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Add a disable_connections flag to create_entity for rolling stock types to disable autoconnecting to other rolling s

Post by boskid »

For 2.1 i added auto_connect parameter to rolling stocks creation through LuaSurface::create_entity.

I tried to also add this to clone but none of my attempts looked reasonable (in terms of code quality) so i decided to abandon this for now - clone is not as easy to extend as create_entity since with create_entity the entity itself can look at the additional lua parameters directly while with clone they have to be parsed on lua api end and then passed through all intermediate layers. If this was to be added, i think i would prefer to only implement this for LuaEntity::clone and ignore support for LuaSurface::clone_area, LuaSurface::clone_brush and LuaSurface::clone_entities.
Post Reply

Return to “Implemented mod requests”