-- place robot spawner one below bottom left/right corner of tunnel if not l then -- CHANGE VALUES BELOW TO CONFIGURE TUNNEL l=20 -- tunnel length w=3 -- tunnel width h=2 -- tunnel height: 1 or 2 a="N" -- tunnel direction: N S E W s="R" -- side of tunnel spawner is at: L R f="default:cobble" -- place block if no floor generate_power=0 -- dont use power to dig, fails if node requires power -- generate_power=0.04 -- amount of power to generate each dig fuel="default:coal" -- DON'T TOUCH ANYTHING BELOW HERE x=0 ; y=0 ; dx=1 ; m=0 as={["N"]=0,["W"]=90,["S"]=180,["E"]=270} ; turn.angle(as[a]) if s=="L" then dx=-1 ; x = w end elseif m==0 then node=read_node.forward() if node=="air" then m=1 elseif generate_power then if machine.energy() < generate_power then machine.generate_power(fuel, generate_power) else if not dig.forward() then self.remove() end m=1 end else if not dig.forward() then self.remove() end m=1 end else local function check_and_place_floor(where) local node = read_node[where]() if node=="air" then if not place[where](f) then self.remove() end end end x=x+dx if x==w or x==-1 then dx=dx*-1 ; x=x+dx -- reverse X direction y=y+1 if y==h then l=l-1 ; if l<=0 then self.remove() end -- tunnel completed -- move back to ground before moving forward if y>1 then if not move.down() then self.remove() end end y=0 check_and_place_floor("forward_down") if not move.forward() then self.remove() end else if not move.up() then self.remove() end end elseif dx==1 then if y==0 then check_and_place_floor("left_down") end if not move.left() then self.remove() end else if y==0 then check_and_place_floor("right_down") end if not move.right() then self.remove() end end m=0 end