Page 1 of 1

fast_replace argument for can_place_entity

Posted: Sat Dec 06, 2025 9:55 pm
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 104 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 104 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.