LuaEntity::get_rail_signals // LuaEntity::get_rail_signal_positions

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
dewiniaid
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 07, 2017 8:50 pm
Contact:

LuaEntity::get_rail_signals // LuaEntity::get_rail_signal_positions

Post 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.

User avatar
SupplyDepoo
Filter Inserter
Filter Inserter
Posts: 284
Joined: Sat Oct 29, 2016 8:42 pm
Contact:

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

Post by SupplyDepoo »

+1 This would be great to have for my mod.

Post Reply

Return to “Modding interface requests”