There doesn't seem to be the same for tiles in the API right now.
I can emulate something similar using:
(please note this is mostly pseudocode)
1) surface.get_tile
Code: Select all
newTile --table filled with the tile's place_result name and collision_mask data etc
oldTile = surface.get_tile(x, y)
canPlace = true
for layer, _ in pairs(newTile.collision_mask) do
if oldTile.collides_with(layer) then
canPlace = false
break
end
end
Code: Select all
if surface.find_tiles_filtered{position=newTile.position, radius=0, collision_mask=newTile.collision_mask} == nil then
canPlace = true
end
I think that #1 is probably the better way to approach this currently, since I think #2 would have a lot of unnecessary checking for the existence of empty arguments, and checking place-ability isn't what it was for. But it would be nice to have a concrete (lol) method in for it in the API
anyway i'm new to all of this; i hope this comes across ok

EDIT:
Honktown on the discord server came up with a new idea that will work for this, which based on how the tile items have a place_result data which then sets the tile, maybe this is as intended. Tiles can always be placed afterall... It would still be nice to have a "shortcut" but this is probably the closest solution as the API is now

Code: Select all
if surface.can_place_entity{name="tile-ghost", position=newTile.position, inner_name=newTile.name} then
surface.set_tile(<etc>)
end