Hey there everyone!
I've decided to try my hands at modding, and wanted to make a railway crossing, which flashes it's lights when a train is approaching, so I don't die.
An obvious part of the process is detecting an inbound train, to do this, I've been trying to find out how the signals work, however I can't seem to find the code for them.
The signal entity itself just defines that it's type is "rail-signal", but I haven't been able to find anything defining that type anywhere.
If any of you lovely people would be able to point in in the right direction, that'd be awesome
Detecting trains on the track
Re: Detecting trains on the track
All actual types are in the C++ code, so that would explain why you can't find anything.Hanse00 wrote:The signal entity itself just defines that it's type is "rail-signal", but I haven't been able to find anything defining that type anywhere.
Perhaps the best option here would be using findentitiesfiltered with a bounding box around the crossing
Code: Select all
local crossing = {position = {x=3200, y=1234}, size = {x=50, 20}}
local train = game.findentitiesfiltered{type="locomotive", area={
{crossing.position.x - crossing.size.x, crossing.position.y - crossing.size.y},
{crossing.position.x + crossing.size.x, crossing.position.y + crossing.size.y}
}
if #train then -- findentitiesfiltered returns a table, if it's not empty
-- do code for flashing lights
end
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me
Or drop into #factorio on irc.esper.net
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me
Or drop into #factorio on irc.esper.net