71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
is_air = function(pos)
local n = sorcery.lib.node.force(pos)
if n.name == 'air' then return true end
local d = minetest.registered_nodes[n.name]
if not d then return false end
return not d.walkable
end;
get_arrival_point = function(pos)
local air = sorcery.lib.node.is_air
if air(pos) then
local n = {x=0,y=1,z=0}
if air(vector.add(pos,n)) then return pos end
local down = vector.subtract(pos,n)
if air(down) then return down end
else return nil end
end;
amass = function(startpoint,names,directions)
if not directions then directions = ofs.neighbors end
local nodes, positions, checked = {},{},{}
local checkedp = function(pos)
for _,v in pairs(checked) do
|
>
>
>
>
>
>
>
>
|
|
<
<
<
<
>
>
>
|
>
>
>
>
>
>
>
|
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
is_air = function(pos)
local n = sorcery.lib.node.force(pos)
if n.name == 'air' then return true end
local d = minetest.registered_nodes[n.name]
if not d then return false end
return not d.walkable
end;
is_clear = function(pos)
if not sorcery.lib.node.is_air(pos) then return false end
local ents = minetest.get_objects_inside_radius(pos,0.5)
if #ents > 0 then return false end
return true
end;
get_arrival_point = function(pos)
local try = function(p)
local air = sorcery.lib.node.is_clear
if air(p) then
if air(vector.offset(p,0,1,0)) then return p end
if air(vector.offset(p,0,-1,0)) then return vector.offset(p,0,-1,0) end
end
return false
end
do local t = try(pos) if t then return t end end
for _,o in pairs(ofs.neighbors) do
local p = vector.add(pos, o)
do local t = try(p) if t then return t end end
end
end;
amass = function(startpoint,names,directions)
if not directions then directions = ofs.neighbors end
local nodes, positions, checked = {},{},{}
local checkedp = function(pos)
for _,v in pairs(checked) do
|