Page 1 of 1
LuaControl.can_place_tile
Posted: Thu Nov 13, 2025 7:02 pm
by protocol_1903
Same as LuaControl.can_place_entity but for tiles, to run easier checks on normal tile buildability rules
Re: LuaControl.can_place_tile
Posted: Fri Nov 14, 2025 2:47 pm
by curiosity
Surely you'd want can_place_tiles more. I don't imagine it's often the case that you want to check only a single tile.
(also, can_place_entity is found in LuaPlayer and LuaSurface, not in LuaControl; I'd expect you want the tile function for both)
Re: LuaControl.can_place_tile
Posted: Fri Nov 14, 2025 4:28 pm
by Rseding91
By placing a given tile it may make placing another invalid (tile placement rules can require you do not build within x distance of another tile). So can place tiles is not likely to be super useful.
Re: LuaControl.can_place_tile
Posted: Sun Nov 16, 2025 3:14 am
by Quorken
Rseding91 wrote: Fri Nov 14, 2025 4:28 pm
By placing a given tile it may make placing another invalid (tile placement rules can require you do not build within x distance of another tile). So can place tiles is not likely to be super useful.
That is kinda true, though it's more that it would create a potential trap for modders, who don't realize this, and then try to use can_place_tiles on tiles where the placement rules include such a restriction - never mind how other tiles/entities might change after each tile is placed (either due to prototype/built-in or scripted behavior). The only way to accurately resolve can_place_tiles is to, well, simulate the placement of each tile. Which would require actually forking the world and placing each and every tile requested until they are either all place, or one of them fails to place - expensive.
can_place_tile is still useful, though.
A variation of can_place_tile, can_place_any_of_tiles, which returns true if at least one tile in a list can be placed, could be also be useful, and might cover some use cases for can_place_tiles.
Re: LuaControl.can_place_tile
Posted: Sun Nov 16, 2025 5:50 am
by protocol_1903
I'd be expecting this more as a 'does the game engine and the tile placement logic of these tiles make them compatible' check rather than 'could i place this EXACT tile on this EXACT other tile' type beat but an implementation like that could be useful