96 lines
2.3 KiB
Lua
Raw Normal View History

2021-01-15 00:26:36 +01:00
2021-01-17 01:53:46 +01:00
local bpos = {
{x=-1265,y=40,z=802},
{x=-1265,y=40,z=972},
{x=-1443,y=40,z=972},
{x=-1443,y=40,z=802}
}
local wbtarget = bpos[1]
2021-01-15 00:26:36 +01:00
local function between(x, y, z) -- x is between y and z (inclusive)
return y <= x and x <= z
end
2021-01-17 01:53:46 +01:00
local function mkposvec(vec)
vec.x=vec.x + 30927
vec.y=vec.y + 30927
vec.z=vec.z + 30927
return vec
end
local function normvec(vec)
vec.x=vec.x - 30927
vec.y=vec.y - 30927
vec.z=vec.z - 30927
return vec
end
2021-06-29 11:51:21 +02:00
local wall_pos1={x=-1254,y=4,z=791}
local wall_pos2={x=-1454,y=80,z=983}
local iwall_pos1={x=-1264,y=4,z=801}
local iwall_pos2={x=-1444,y=80,z=973}
2021-01-15 00:26:36 +01:00
local function in_cube(tpos,wpos1,wpos2)
local xmax=wpos2.x
local xmin=wpos1.x
local ymax=wpos2.y
local ymin=wpos1.y
local zmax=wpos2.z
local zmin=wpos1.z
if wpos1.x > wpos2.x then
xmax=wpos1.x
xmin=wpos2.x
end
if wpos1.y > wpos2.y then
ymax=wpos1.y
ymin=wpos2.y
end
if wpos1.z > wpos2.z then
zmax=wpos1.z
zmin=wpos2.z
end
if between(tpos.x,xmin,xmax) and between(tpos.y,ymin,ymax) and between(tpos.z,zmin,zmax) then
return true
end
return false
end
local function in_wall(pos)
if in_cube(pos,wall_pos1,wall_pos2) and not in_cube(pos,iwall_pos1,iwall_pos2) then
return true end
return false
end
2021-06-29 11:51:21 +02:00
local lwltime=0
2021-01-15 00:26:36 +01:00
scaffold.register_template_scaffold("WallTool", "scaffold_walltool", function(pos)
2021-06-29 11:51:21 +02:00
if os.clock() < lwltime then return end
lwltime=os.clock()+.5
2021-01-15 00:26:36 +01:00
local lp=minetest.localplayer:get_pos()
local p1=vector.add(lp,{x=5,y=5,z=5})
local p2=vector.add(lp,{x=-5,y=-5,z=-5})
local nn=nlist.get_mclnodes()
2021-06-29 11:51:21 +02:00
local cobble='mcl_core:cobble'
2021-01-15 00:26:36 +01:00
table.insert(nn,'air')
2021-06-29 11:51:21 +02:00
--local nds,cnt=minetest.find_nodes_in_area(p1,p2,nn,true)
--local nds=minetest.find_nodes_near_except(lp,5,{cobble})
local i=1
local nds=minetest.find_nodes_near(lp,10,{'air'})
for k,vv in pairs(nds) do
2021-01-15 00:26:36 +01:00
if vv and in_wall(vv) then
2021-06-29 11:51:21 +02:00
if i > 8 then return end
i = i + 1
2021-01-15 00:26:36 +01:00
local nd=minetest.get_node_or_nil(vv)
2021-06-29 11:51:21 +02:00
if nd and nd.name ~= 'air' then
2021-01-15 00:26:36 +01:00
scaffold.dig(vv)
2021-06-29 11:51:21 +02:00
else
ws.place(vv,{cobble})
2021-01-15 00:26:36 +01:00
end
2021-06-29 11:51:21 +02:00
2021-01-15 00:26:36 +01:00
end
2021-01-17 01:53:46 +01:00
end
end)