From 20b8961640b6c22d4149f7268d403cb4609a03fb Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sun, 7 Jun 2020 18:34:21 +0200 Subject: New file Structure --- src/common/common.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/common/common.lua (limited to 'src/common/common.lua') 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 -- cgit v1.2.3