Reading "Trains in block" from a rail entity

Post Reply
Pendarin
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Dec 29, 2018 1:07 am
Contact:

Reading "Trains in block" from a rail entity

Post by Pendarin »

The vanilla GUI shows "Trains in block" when you hover over a rail entity. I am in need of exactly that programmatically. I can't seem to find any way to do this. My goal is to determine whether it is safe to place a carriage on a given rail. Not just whether I can (the normal LuaSurface:can_place_entity() does this), but whether it is safe to do.

Thanks!

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Reading "Trains in block" from a rail entity

Post by Rseding91 »

I'll see if that value is safe to expose to the Lua API.
If you want to get ahold of me I'm almost always on Discord.

Pendarin
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Dec 29, 2018 1:07 am
Contact:

Re: Reading "Trains in block" from a rail entity

Post by Pendarin »

That would be excellent. As you can imagine, calculating this in Lua is expensive and complicated since Lua isn't exposed at all to the rail block constructs the engine uses. So, in Lua I'd have to model the entire thing by scanning rails, finding nearby signals, checking for branches and loops, etc. Just having the trains in block value available removes the need for all of that in Lua.

Post Reply

Return to “Implemented mod requests”