add get_neighbors function to api.

This commit is contained in:
trans_soup 2023-10-16 19:17:52 +02:00
parent da9fb8970d
commit 6478e66ef7

View file

@ -55,3 +55,14 @@ function blockgame.random_walk (data)
end
return pos
end
function blockgame.get_neighbors (pos, neighborhood)
neighborhood = neighborhood or blockgame.vector.dirs
local neighbors = {}
for _, dir in pairs(neighborhood) do
table.insert(neighbors, pos + dir)
end
return neighbors
end