wallbot: fix freeze
parent
bf4d991852
commit
a95e4cccfd
|
@ -1,7 +1,3 @@
|
|||
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}
|
||||
|
||||
local bpos = {
|
||||
{x=-1265,y=40,z=802},
|
||||
|
@ -30,6 +26,10 @@ local function normvec(vec)
|
|||
vec.z=vec.z - 30927
|
||||
return vec
|
||||
end
|
||||
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}
|
||||
|
||||
local function in_cube(tpos,wpos1,wpos2)
|
||||
local xmax=wpos2.x
|
||||
|
@ -64,69 +64,32 @@ local function in_wall(pos)
|
|||
return false
|
||||
end
|
||||
|
||||
|
||||
local lwltime=0
|
||||
scaffold.register_template_scaffold("WallTool", "scaffold_walltool", function(pos)
|
||||
if os.clock() < lwltime then return end
|
||||
lwltime=os.clock()+.5
|
||||
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()
|
||||
local cobble='mcl_core:cobble'
|
||||
table.insert(nn,'air')
|
||||
local nds,cnt=minetest.find_nodes_in_area(p1,p2,nn,true)
|
||||
for k,v in pairs(nds) do for kk,vv in pairs(v) do
|
||||
--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
|
||||
if vv and in_wall(vv) then
|
||||
scaffold.place_if_needed({'mcl_core:cobble'},vv)
|
||||
if i > 8 then return end
|
||||
i = i + 1
|
||||
local nd=minetest.get_node_or_nil(vv)
|
||||
if nd and nd.name ~= 'mcl_core:cobble' then
|
||||
if nd and nd.name ~= 'air' then
|
||||
scaffold.dig(vv)
|
||||
else
|
||||
ws.place(vv,{cobble})
|
||||
end
|
||||
|
||||
end
|
||||
end end
|
||||
end)
|
||||
local posi=1
|
||||
|
||||
local function flythere()
|
||||
minetest.settings:set_bool('noclip',true)
|
||||
minetest.settings:set_bool('scaffold_walltool',true)
|
||||
minetest.settings:set_bool("pitch_move",true)
|
||||
minetest.settings:set_bool("free_move",true)
|
||||
minetest.settings:set_bool("continuous_forward",true)
|
||||
autofly.aim(wbtarget)
|
||||
core.set_keypress("special1", true)
|
||||
end
|
||||
|
||||
local function stopflight()
|
||||
minetest.settings:set_bool("continuous_forward",false)
|
||||
minetest.settings:set_bool('scaffold_walltool',false)
|
||||
minetest.settings:set_bool("noclip",false)
|
||||
minetest.settings:set_bool("pitch_move",false)
|
||||
core.set_keypress("special1", false)
|
||||
end
|
||||
|
||||
local function findholes()
|
||||
local lp=minetest.localplayer:get_pos()
|
||||
local p1=vector.add(lp,{x=15,y=60,z=15})
|
||||
local p2=vector.add(lp,{x=-15,y=-60,z=-15})
|
||||
local nn=nlist.get_mclnodes()
|
||||
table.insert(nn,'air')
|
||||
local nds,cnt=minetest.find_nodes_in_area(p1,p2,nn,true)
|
||||
for k,v in pairs(nds) do for kk,vv in pairs(v) do
|
||||
if vv and in_wall(vv) then
|
||||
wbtarget=vv
|
||||
end
|
||||
end end
|
||||
end
|
||||
math.randomseed(os.time())
|
||||
scaffold.register_template_scaffold("WallABot", "scaffold_wallabot", function(pos)
|
||||
local lp=minetest.localplayer:get_pos()
|
||||
if vector.distance(lp,bpos[posi]) < 3 then
|
||||
posi=posi+1
|
||||
if posi > 4 then posi=1 end
|
||||
wbtarget=bpos[posi]
|
||||
wbtarget.y=math.random(15,65)
|
||||
end
|
||||
local tn=minetest.get_node_or_nil(wbtarget)
|
||||
if tn and tn.name == 'mcl_core:cobble' then wbtarget=bpos[i] end
|
||||
flythere()
|
||||
findholes()
|
||||
end,false,function()
|
||||
stopflight()
|
||||
end)
|
||||
|
|
Loading…
Reference in New Issue