aboutsummaryrefslogtreecommitdiff
path: root/src/common/common.lua
blob: 2288a4d68b629b347f6b04c9d3bccf4e6002a8c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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