How to get rail path

Place to get help with not working mods / modding interface.
Post Reply
Natha
Fast Inserter
Fast Inserter
Posts: 183
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

How to get rail path

Post by Natha »

Hello everyone,

is there a possibility to get the next 5 rails of a track (in each direction)

example:

_ _ _ _ _ _ _ (rails...)
1 2 3 4 5 6 7

i have rail 4 selected (as entity object), now i want to have 1-3 and 5-7 in a table.

But only the rails which are connected each other and make up a rail track.

It should work like the rail signals, they also can find all rails until next signal.


Thx

chibbi
Manual Inserter
Manual Inserter
Posts: 4
Joined: Fri Dec 01, 2023 7:47 pm
Contact:

Re: How to get rail path

Post by chibbi »

any update? :D

mrvn
Smart Inserter
Smart Inserter
Posts: 5710
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: How to get rail path

Post by mrvn »


chibbi
Manual Inserter
Manual Inserter
Posts: 4
Joined: Fri Dec 01, 2023 7:47 pm
Contact:

Re: How to get rail path

Post by chibbi »

Ah thanks, nice to know that exists inside of the modding api.

Are there sources for how the game has implemented some/this function(s)?
In my case, i would like to know how the game calculates which rails are connected with each other.

I want/need to do graph analysis on train networks, which is easier with an existing graph library. An existing library or not using lua makes it impossible as far as i know, to do that inside of a mod.Thats why i want to implement this function myself ot find the connected rails with only the information given in blueprints.

The problem is that i have trouble creating a reliably working implementation of this, but cannot just use the lua api of the game.
I hope to find out how the game parses the blueprint to do the same outside of the game (but less general, basically just need the parsing of rails).

mrvn
Smart Inserter
Smart Inserter
Posts: 5710
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: How to get rail path

Post by mrvn »

In game each end of a rail has a fixed sized array of 3 connected rail entities, pointers to the other rails I assume. See one of the recent FFFs about the new curves mentioning the 3 connected rails limit.

I don't believe any of that is encoded in blueprints. They simply have the placement of each rail and that is it. The connections happen only when rails are built from ghosts and you will have to figure out those connections yourself.

But again look at the recent FFF that talks about how rails are implemented internally and why the new curves are so much better.

Post Reply

Return to “Modding help”