add get_neighbors
function to api.
This commit is contained in:
parent
da9fb8970d
commit
6478e66ef7
1 changed files with 11 additions and 0 deletions
|
@ -55,3 +55,14 @@ function blockgame.random_walk (data)
|
||||||
end
|
end
|
||||||
return pos
|
return pos
|
||||||
end
|
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
|
||||||
|
|
Loading…
Reference in a new issue