aboutsummaryrefslogtreecommitdiff
path: root/src/common/common.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/common.lua')
-rw-r--r--src/common/common.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/common/common.lua b/src/common/common.lua
new file mode 100644
index 0000000..2288a4d
--- /dev/null
+++ b/src/common/common.lua
@@ -0,0 +1,24 @@
+function skycraft.get_far_node(pos)
+ local node = minetest.get_node(pos)
+ if node.name ~= "ignore" then
+ return node
+ end
+ minetest.get_voxel_manip():read_from_map(pos, pos)
+ return minetest.get_node(pos)
+end
+
+function skycraft.find_free_position_near(pos)
+ local tries = {
+ {x = 1, y = 0, z = 0},
+ {x = -1, y = 0, z = 0},
+ {x = 0, y = 0, z = 1},
+ {x = 0, y = 0, z = -1},
+ }
+ for _, d in pairs(tries) do
+ local p = vector.add(pos, d)
+ if not minetest.registered_nodes[minetest.get_node(p).name].walkable then
+ return p, true
+ end
+ end
+ return pos, false
+end