Combined request for train/rails/pathfinder read access

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
Godmave
Long Handed Inserter
Long Handed Inserter
Posts: 87
Joined: Tue Nov 15, 2016 3:52 pm
Contact:

Combined request for train/rails/pathfinder read access

Post by Godmave » Tue Jun 12, 2018 9:35 am

LuaTrain: pathfinder stats
- path_rails_to_destination - number of rails to the current destination
- (opt) path_blocks_to_destination - array of RailBlock tables

LuaEntity type="train-stop"
- connected_rail

LuaEntity type="rail"
- rail_blocks - table with one or two RailBlock tables

RailBlock table
- block-number
- length in rails
- number of trains in this block (in most cases 0 or 1, so could even be train_in_block => LuaTrain or nil)
- array of bordering rail-signals

(opt) direct pathfinder access
LuaPathfinder.path(LuaEntity:startRail, LuaEntity:endRail) or LuaPathfinder.path(LuaTrain:train, LuaEntity:endRail)
- path_distance
- pathed_blocks

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 3740
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Combined request for train/rails/pathfinder read access

Post by eradicator » Tue Jun 12, 2018 11:34 am

Godmave wrote: LuaEntity type="train-stop"
- connected_rail
Oh yes. Having to guess this by direction is so ugly.

Aidiakapi
Inserter
Inserter
Posts: 48
Joined: Fri Apr 14, 2017 6:13 pm
Contact:

Re: Combined request for train/rails/pathfinder read access

Post by Aidiakapi » Tue Jun 12, 2018 2:40 pm

Godmave wrote:LuaEntity type="train-stop"
- connected_rail
Would this be the piece of rail that the train stop is connected to, or piece of rail where a train which is stopped at the train stop, would actually stop (the rail before).
Godmave wrote:LuaEntity type="rail"
- rail_blocks - table with one or two RailBlock tables
Every piece of rail is exclusively part of one block.
Godmave wrote:RailBlock table
- block-number
- length in rails
- number of trains in this block (in most cases 0 or 1, so could even be train_in_block => LuaTrain or nil)
- array of bordering rail-signals
Distinction between signals that enter the block, and leave the block is important.
There could be multiple trains in a block.
Length of the rail doesn't make much sense, since it wouldn't know length along which path in the block. (Every block can have multiple paths.)

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

Re: Combined request for train/rails/pathfinder read access

Post by Godmave » Tue Jun 12, 2018 3:22 pm

Aidiakapi wrote:
Godmave wrote:LuaEntity type="train-stop"
- connected_rail
Would this be the piece of rail that the train stop is connected to, or piece of rail where a train which is stopped at the train stop, would actually stop (the rail before).
You should know that better than anyone else, since you wrote the code to search for it in the can_spawn_train function ;)
Aidiakapi wrote:
Godmave wrote:RailBlock table
- block-number
- length in rails
- number of trains in this block (in most cases 0 or 1, so could even be train_in_block => LuaTrain or nil)
- array of bordering rail-signals
Distinction between signals that enter the block, and leave the block is important.
Ok
Aidiakapi wrote: There could be multiple trains in a block.
Ok
Aidiakapi wrote: Length of the rail doesn't make much sense, since it wouldn't know length along which path in the block. (Every block can have multiple paths.)
Yeah, like we discussed in discord, this one makes no sense then.

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

Re: Combined request for train/rails/pathfinder read access

Post by Rseding91 » Wed Jun 13, 2018 1:17 pm

What's the utility of being able to find rail paths through script? The rail path finder is built specifically for trains so it expects a front rail + direction of search, back rail + direction of search, and list of rail ends to path to (rail + direction of travel) and a source train the path will be used for.
If you want to get ahold of me I'm almost always on Discord.

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

Re: Combined request for train/rails/pathfinder read access

Post by Godmave » Wed Jun 13, 2018 1:44 pm

The utility for me was for the teleportation part of the clusterio mod I am working on. And I would effectively only need the currently calculated distance to destination from the pathfinder.
Since I can not show a map view of trains on other instances, I wanted at least to show a progress bar for the distance a train has still to go until it reaches the next teleport station (distance left in relation to total distance).

Another possible thing would have been to say: this train is approaching the teleport station, is less than train length away, and there is nothing between it and the station, so speed it up until it is just before the station (where it has to stop since I can not dismantle moving stuff).
This would give the teleport a nice effect. I could even apply an overlaying effect on top of the train (most likely this will require a mod for the graphics). A flash or something, to hide that the train stops before getting teleported.

The finding of the attached rails and following its path is needed to make sure the destination station is free and there is no train in the way of the teleport.
Being able to easily access those information without having to scan an area and guess around with directions, would be nice. Especially the part for finding signals.

Here is the current version of trying to do that (written by Aidiakapi):
https://github.com/Godmave/factorioClus ... g.lua#L377

I think Aidiakapi even made a lot more stuff that would definitely be faster in c++ than lua.

Post Reply

Return to “Modding interface requests”

Who is online

Users browsing this forum: No registered users