wasplib: add get_reachable_airpocket

master
cora 2021-08-31 21:52:26 +02:00
parent 54b6b951c6
commit b530187316
1 changed files with 13 additions and 0 deletions

View File

@ -843,6 +843,19 @@ function ws.inside_wall(pos)
return false
end
function ws.find_closest_reachable_airpocket(pos)
local lp=ws.dircoord(0,0,0)
local nds=minetest.find_nodes_near(lp,5,{'air'})
local odst=10
local rt=lp
for k,v in ipairs(nds) do
local dst=vector.distance(pos,v)
if dst < odst then odst=dst rt=v end
end
if odst==10 then return false end
return vector.add(rt,vector.new(0,-1,0))
end
-- DEBUG
local function printwieldedmeta()