From 6478e66ef74149e143bbfb3738aecc547f67301f Mon Sep 17 00:00:00 2001 From: trans_soup <> Date: Mon, 16 Oct 2023 19:17:52 +0200 Subject: [PATCH] add `get_neighbors` function to api. --- mods/bg_api/util_node.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mods/bg_api/util_node.lua b/mods/bg_api/util_node.lua index 21a9fc8..711171c 100644 --- a/mods/bg_api/util_node.lua +++ b/mods/bg_api/util_node.lua @@ -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