#Console command for deleting orphaned rails?
1 messages · Page 1 of 1 (latest)
My solution for that is using grid aligned rail blueprints.
When changing some rails, like adding an intersection, I deconstruct a generous chunk to prevent this.
You could probably make something using LuaEntity::get_connected_rail
Find all rails in a given area, run that function for each direction and for both ends, delete the rail if one side is empty.
unfortunately no space for grid-aligned stuff atm
oh that looks perfect, thanks
guess ill also check all rails connected to hover target for orphans too
got something working
doesnt prune the whole branch
and personal bots seem to only respond to first order_deconstruction(), but whatever, good enough for my use case
i don't think i saw anything preventing deleting rails that have a train stop attached (?)
nope it doesnt check for / delete the stops / signals / supports
i only really wrote it for the 1-rail branches in the screenshot
https://f.gisadan.dev/dh/gNUOxC025FUYaCq/ssr-2025-09-14_16.44.21.mp4
stopped there cuz i learned i kinda hate lua lol
i'd just be worried that it eats rails that lead into deadend stations