Page 1 of 1

get_connected_rail() for rail ghost entities

Posted: Thu Jun 18, 2026 5:43 am
by MrFastZombie
Tracing a line of live rails is easy as you can use get_connected_rail() to move down the line. Ghost rails however, cannot use get_connected_rail(), meaning you have to manually scan for nearby rails which can be imprecise and much more complicated if you need to make it precise.

To give a usecase example, a mod I am working on needs to trace rail ghost lines to estimate the materials needed to build them, but I absolutely want to avoid edge-cases like if another ghost rail line crosses it. Finding the next connected piece currently involves manually checking for every possible next piece at the exact possible locations from the current rail and making sure it is orientated correctly.

I'm not sure what the exact best way to implement this would be, but I reckon that calling get_connected_rail() on a live rail should not show ghost rails if used in the way it is now to avoid creating unexpected behavior in mods currently using that function. Perhaps it could be an optional parameter to enable ghost rail results, it could be a new function specifically for ghost rails, or it could only show ghost rails when called from a ghost rail.