Page 1 of 1

LuaEntity::get_rail_signals // LuaEntity::get_rail_signal_positions

Posted: Sun Nov 04, 2018 5:30 am
by dewiniaid
I'm working on a mod for rail signal placement and have run into my latest dose of pain, namely this:

Image

I've managed to work out logic for how to walk along railways and -- with an excessive amount of hard-coding -- where signals might be for any given chunk of rail. Since the presence of junctions that aren't even related to the same piece of track can affect legal signal placement without creating a collision, this particular case is hard to code for without more repeated get_connected_rail calls.

It would be handy to -- given a particular section of a single rail-entity -- get all of the legal positions for a signal. For my purpose I only really need a position, but something like this would be a useful format:

Code: Select all

{
	[defines.rail_direction_front] = {   -- Signals for trains moving towards the 'front' of the track -- i.e. eastbound for horizontal straight rail
		{ index=1, position={...}, direction=... }
		-- no entries for signals that can't currently be placed due to rail limitations.  
		-- (I'm placing ghosts though, so trees/rocks shouldn't prevent an entry from being present
	}
A counterpart to this would be a means to get all the signals that are 'attached' to this rail. (I realize that this isn't 100% accurate, since a junction might have a straight rail and two curved rails in opposite directions sharing one signal.

Re: LuaEntity::get_rail_signals // LuaEntity::get_rail_signal_positions

Posted: Sun Mar 03, 2024 1:24 pm
by SupplyDepoo
+1 This would be great to have for my mod.