fast_replace argument for can_place_entity

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
Osmo
Fast Inserter
Fast Inserter
Posts: 205
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

fast_replace argument for can_place_entity

Post by Osmo »

Currently, calling LuaSurface.can_place_entity returns true if an entity can be placed by fast-replacing even if it can't be placed normally.
For example, a call to can_place_entity to place a wooden chest over an iron chest returns true, even though they collide.
изображение.png
изображение.png (134.8 KiB) Viewed 74 times
What i'm doing in a mod is when a "roof" entity is placed, place a 1x2 "wall" entity near it. If wall cannot be placed, i destroy both the wall and roof.
So i first check if wall can be placed by using LuaSurface.can_place_entity, however if there is another wall already there, but facing a different direction, can_place_entity returns true, causing two walls to be placed on top of each other.
изображение.png
изображение.png (68.1 KiB) Viewed 74 times
I can check if LuaSurface.can_fast_replace also return true and if so, don't place the wall, however this also returns true when placing a wall on top of a ghost wall, causing it to not be placed which is not what is needed.
So rather than hacky workarounds, it'd be better if can_place_entity took a fast_replace argument, defaulting to true, but when false, the function will return false if an entity can only be placed with fast replace.
Post Reply

Return to “Modding interface requests”