Page 1 of 1

Add can_player_place functionality

Posted: Fri Oct 20, 2017 4:53 pm
by blueblue
I need a function that allows me to check wether a player could place an entity. The surface.can_place function returns false if a placement location e.g. of an inserter is blocked by items, which is not what I want. My current method to deal with this is removing all items in the target location, calling the can_place method and putting the items back in place if the entity is still not placeable. I'm sure this is not good for performance and there are probably a couple other issues with that method.

I suggest something like a flag ignore_items in LuaSurface::can_place or a function LuaPlayer::can_player_build.

See also viewtopic.php?f=28&t=53503