Find colliding entities

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
mickael9
Fast Inserter
Fast Inserter
Posts: 112
Joined: Mon Mar 14, 2016 4:04 am
Contact:

Find colliding entities

Post by mickael9 »

I need to get a list of all entities that would collide with a newly-created entity (in order to deconstruct them before placing a new one).
I also need to filter the resulting list to exclude things such as ghost entities or entities marked for deconstruction,.

Right now, I use find_entities_filtered with the area set to the collision box of the yet-to-create entity, centered around its position.
But this doesn't work on 45°rails because their bounding box has an orientation which is ignored by find_entities_filtered.

The best way to do this would be to have a dedicated function:

LuaSurface::find_colliding_entities{name = ..., position = ..., direction = ...}
Returns a list of entities that would collide when placing this entity

Another alternative would be to support the undocumented BoundingBox::orientation property in find_entities/find_entities_filtered although that requires a bit more work (since you have to actually compute the bounding box from the prototype's collision box: center it, rotate it)
Post Reply

Return to “Modding interface requests”