LuaControl.can_place_tile

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
protocol_1903
Filter Inserter
Filter Inserter
Posts: 392
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

LuaControl.can_place_tile

Post by protocol_1903 »

Same as LuaControl.can_place_entity but for tiles, to run easier checks on normal tile buildability rules
Py and PyBlock developer, wielder of LUA in arbitrary ways. I make mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903
curiosity
Filter Inserter
Filter Inserter
Posts: 711
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: LuaControl.can_place_tile

Post 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)
Rseding91
Factorio Staff
Factorio Staff
Posts: 16285
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaControl.can_place_tile

Post 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.
If you want to get ahold of me I'm almost always on Discord.
Quorken
Inserter
Inserter
Posts: 38
Joined: Mon Aug 18, 2025 3:53 pm
Contact:

Re: LuaControl.can_place_tile

Post 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.
User avatar
protocol_1903
Filter Inserter
Filter Inserter
Posts: 392
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Re: LuaControl.can_place_tile

Post 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
Py and PyBlock developer, wielder of LUA in arbitrary ways. I make mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903
Post Reply

Return to “Modding interface requests”