Page 1 of 1

Rail LuaEntity - query rail block state

Posted: Wed Jun 27, 2018 3:05 pm
by shanemadden
When looking at a rail entity, as far as I can tell the best way to get the state of the train block is to find a signal entity with find_entities_filtered to check its
defines.signal_state. I have a new mod https://mods.factorio.com/mod/train-scaling that builds trains on demand, and it'd be great to have a simple check for whether it's safe for the construction station to start building.

Would it be possible to have an attribute on the rails themselves that would either contain information about the rail block's occupation/reservation state, or an attribute with an array of LuaEntity references to the signal(s) that control entry into the block, to avoid a computationally expensive search for signal entities?

Re: Rail LuaEntity - query rail block state

Posted: Wed Jun 27, 2018 5:47 pm
by Godmave

Re: Rail LuaEntity - query rail block state

Posted: Fri Jun 29, 2018 11:41 am
by Rseding91
This is something I'm looking into.

Re: Rail LuaEntity - query rail block state

Posted: Sat Feb 09, 2019 9:47 pm
by shanemadden
The new LuaEntity::trains_in_block in 0.17 will fit my needs for this request, this can be moved to Implemented.