I had to use a function like this in the mars mod
viewtopic.php?f=11&t=13913, to check if the air generator not was on a open space.
it checks 10 nodes in the directions: x+,x-,z+,z-,y+
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
start=0
distance=10
for i=start,start+distance,1 do
local p1={x=pos.x+i,y=pos.y,z=pos.z}
local p2={x=pos.x-i,y=pos.y,z=pos.z}
local p3={x=pos.x,y=pos.y,z=pos.z+i}
local p4={x=pos.x,y=pos.y,z=pos.z-i}
local p5={x=pos.x,y=pos.y+i,z=pos.z}
if minetest.get_node(p1) and minetest.get_node(p1).name~="air" then --x+
return false
end
if minetest.get_node(p2) and minetest.get_node(p2).name~="air" then --x-
return false
end
if minetest.get_node(p3) and minetest.get_node(p3).name~="air" then --z+
return false
end
if minetest.get_node(p4) and minetest.get_node(p4).name~="air" then --z-
return false
end
if minetest.get_node(p5) and minetest.get_node(p5).name~="air" then --y+
return false
end
end
return true