[Request] Better train control via mods

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
justK
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Mar 10, 2017 12:12 pm
Contact:

[Request] Better train control via mods

Post by justK »

Hello,

I've spent some time for searching by forum but I'm unable to find this kind of questions/requests, so I've created this topic.

I'm wondering if it possible to provide more train control to scripts? I mean, for example, add some properties/actions/events? As for me, this may be something like below:

Properties:
train_path which will return, for example, array of rail segments/blocks where train is planning to go on his way to target station
brake_point which will return the point/rail segment where train would stop if begin braking immediately
locomotive_frontmovers and (optionally) locomotive_backmovers which will return an array of locomotives in the train, which have positive (and negative) speed at the request moment (or will have in few ticks) so it would be easier to understand, which loco is moving forward, for example, avoiding questions like this: viewtopic.php?t=34250&p=214801 (sorry that this isn't a link, this is my first post). May be this would be a good idea to refresh this value when train changed state (wants to start moving), but still have 0 speed

Events:
on_path_calculated - fires when train is calculating/recalculating his path
on_locomotive_movers_changed - fires when locomotive_[front|back]movers are changed (but, possibly, this will be overkill when another events like on_train_changed_state)

Actions:
force_path_recalculate(train) - allow train to re-calculate path on demand, for example to change route/choose different station with the same name of original one is became occupied without waiting until trains arrives at signal (or whenever path is recalculating in current version).
force_stop(train) and force_start(train) - request trains to stop and resume their movement not only on signals and stations. Possibly, would be useful for train hijacking for player resupplying/train taxi servicing or even to stop being killed by train:)
May be also something to control railroad signals, for example with circuit logic (like add conditions for changing signals state)

I hope these additions required not only by me so this list may be extended by other users.

Small topic related off-topic: I think that it would be perfect idea to add condition for train to start moving in addition to existing leaving conditions. Such as Move to the station in plan only when some condition is true. That would allow train to start moving only when needed (for example, simplest "if fuel < X then station named XXX became available" will cause skipping station XXX in schedule when train has enough fuel and move to that station when this station is next in schedule and fuel is going to be depleted, but such kind of condition should be as wide as possible, for example, including cargo's content)

justarandomgeek
Filter Inserter
Filter Inserter
Posts: 300
Joined: Fri Mar 18, 2016 4:34 pm
Contact:

Re: [Request] Better train control via mods

Post by justarandomgeek »

The train's state should do much of what you want

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2915
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [Request] Better train control via mods

Post by Optera »

We already have access to front_movers and back_movers for each train through train.locomotives
However I would like to see an unique identifier for every train which changes whenever players or mods like de-coupler change train composition. An event when such a train change happens would be the cherry on top.

Currently train pathfinding is a black box for modders. All we can do is generate a schedule to send trains to ambiguous stop names. Being able to send trains to a stop with a specific unit_number would go a long way for mods.

train_path returning an array of passed signals sounds nice. Signals should also have a path cost field we can change. With a force_path_recalculation function that would go a long way towards modded train pathfinding.

justK
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Mar 10, 2017 12:12 pm
Contact:

Re: [Request] Better train control via mods

Post by justK »

justarandomgeek wrote:The train's state should do much of what you want
Yep, I agree that this provides some information but... Actually almost everything that it shows is only "Is train moving or not? If not moving - what the reason: waiting on station, no path to the station, signal forces train to stop and so on?" Additionaly, these states are read-only and I have no idea how to force some state, partially that's a reason for "better" in topic name
Optera wrote:We already have access to front_movers and back_movers for each train through train.locomotives
Oh, I just realized that I provided the name similar to the existing one, sorry if that confused someone. I saw and used existing front_movers and back_movers, for me this is really useful, but I mean something that give us a chance to simply get the real front and last loco, without the magic like reading list of locomotives at the both sides, detect the first one on the both sides that have positive/negative speed, etc., like used in the topic Forwardmost Entity of a Train (Train direction) mentioned in my first post here

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2631
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: [Request] Better train control via mods

Post by steinio »

We also need something to set mode to auto or manual and split/merge at position(x).

Greetings steinio
Image

Transport Belt Repair Man

View unread Posts

Post Reply

Return to “Modding interface requests”