train stop id and TrainScheduleRedord.targetid

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
rldml
Fast Inserter
Fast Inserter
Posts: 177
Joined: Sun Mar 06, 2016 2:38 am
Contact:

train stop id and TrainScheduleRedord.targetid

Post by rldml »

Give every train stop an unique ID (like you do it already with trains) and add an attribute to the Class TrainScheduleRecord: targetid.

If the targetid of the next TrainScheduleRecord is set, the method LuaTrain.recalculate_path() has to prioritize the corresponding train stop with the unique id as his target train stop.

Global rule: TrainScheduleRecord.targetid > TrainScheduleRedord.station

If targetid is set and the corresponding train stop doesn't exist anymore, the train behavior should look similar to a train, that can't find a train stop by its name.

The positive effect would be, that we can write specific mods to make train scheduling more dynamic and easier than it is handled now.

Greetings Ronny

User avatar
Godmave
Long Handed Inserter
Long Handed Inserter
Posts: 89
Joined: Tue Nov 15, 2016 3:52 pm
Contact:

Re: train stop id and TrainScheduleRedord.targetid

Post by Godmave »

As a LuaEntitiy the train-stop already got an unique id in the unit_number.

rldml
Fast Inserter
Fast Inserter
Posts: 177
Joined: Sun Mar 06, 2016 2:38 am
Contact:

Re: train stop id and TrainScheduleRedord.targetid

Post by rldml »

Nice!

That means, we only need the extension of TrainScheduleRecord and of LuaTrain.recalculate_path()

Greetings, Ronny

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: train stop id and TrainScheduleRedord.targetid

Post by Rseding91 »

I'm not strictly against the idea but this needs to be thought out more.

What happens once the train reaches the destination?
what happens if there is no path to the destination stop? Should it say "no path" or should it just pick another stop?
How would this information be conveyed to the player in the GUI that the train is preferring a specific stop over "any"?
Should it be copied when the player does copy-paste across trains?
If you want to get ahold of me I'm almost always on Discord.

rldml
Fast Inserter
Fast Inserter
Posts: 177
Joined: Sun Mar 06, 2016 2:38 am
Contact:

Re: train stop id and TrainScheduleRedord.targetid

Post by rldml »

Rseding91 wrote:I'm not strictly against the idea but this needs to be thought out more.

What happens once the train reaches the destination?
Just as it is right now: the train checks and wait for the wait conditions of his actual TrainScheduleRecord and after that it targets the next station in his TrainSchedule-Array. The existing id remains in the TrainScheduleRecord until it was changed through a user or any other entity in the game (like the modder coded it how it can change)
what happens if there is no path to the destination stop? Should it say "no path" or should it just pick another stop?
Exactly the same behavior as the train actually shows, if we work with unique stationnames as targets. If the "targetid" is set with any other value than "0" or "notdefined", the stationname should be completly ignored in this TrainScheduleRecord.
How would this information be conveyed to the player in the GUI that the train is preferring a specific stop over "any"?
Absolute Minimum
Relative Minium
Optimum IMHO
Should it be copied when the player does copy-paste across trains?
yes.

In the moment you start doing TrainScheduleRecord-Logic based on train stop ids you're agree to the fact, that it can mess up your complete train network. It is the part, where train stuff can become complex - like an x-to-y-beltbalancer compared to a simple 2x2-balancer. That's why it should be optional completly

It could be the main argument to leave the usage of this extensions within a mod, because (in the view of a player) there could happen really confusing stuff through this

edit: I clarified some stuff in this post...

Post Reply

Return to “Modding interface requests”