Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- --author - SergOmarov, 2015
- --
- local events=require("event")
- local computer=require("computer")
- local robot=require("robot")
- local term=require("term")
- local x=term.read()
- local z=term.read()
- local inventory_controller=require("component").getPrimary("inventory_controller")
- function refuel()
- if(computer.energy()/computer.maxEnergy())<10 then
- for i = 1, 16 do
- require("component").getPrimary("generator").insert(64)
- end
- end
- end
- robot.select(1)
- times=x*z/25
- events.timer(5,refuel,times)
- function Sides2()
- robot.turnRight()
- mine2(1)
- robot.turnAround()
- mine2(1)
- robot.turnRight()
- end
- local function Sides(ifend)
- robot.select(1)
- if(robot.compareUp()) then
- robot.select(5)
- inventory_controller.equip()
- robot.swingUp()
- inventory_controller.equip()
- robot.select(1)
- end
- if(robot.compareDown()) then
- robot.select(5)
- inventory_controller.equip()
- robot.swingDown()
- inventory_controller.equip()
- robot.select(1)
- end
- end
- function mine1(ismine)
- for j=1,4 do
- robot.select(j)
- if(robot.compare()) then
- robot.select(j+4)
- inventory_controller.equip()
- robot.swing()
- inventory_controller.equip()
- robot.select(1)
- return "move"
- elseif(ismine==true)then
- robot.swing()
- end
- end
- end
- --копает тунель
- function mine(xT)
- for i=1,xT do
- mine1(true)
- Sides()
- robot.forward()
- Sides()
- if(i>1)then
- Sides2()
- end
- end
- for j=1,xT do
- robot.back()
- end
- end
- function mine2(xT)
- for i=1,xT do
- ismove=mine1(false)
- Sides()
- if(ismove=="move")then
- robot.forward()
- Sides()
- end
- end
- if(ismove=="move")then
- for j=1,xT do
- robot.back()
- end
- end
- end
- --перемещается
- function move(xT)
- for j=1,xT do
- robot.forward()
- end
- end
- mine(x)
- --теперь ответвления
- lZ=math.floor(z/2)
- robot.turnLeft()
- for ii=1,x,3 do--левое
- mine(lZ)
- robot.turnRight()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.turnLeft()
- end
- robot.turnAround()
- for ii=1,x,3 do-- правое
- mine(lZ)
- robot.turnRight()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.turnLeft()
- end
- mine(lZ)
- robot.turnRight()
- robot.forward()
- robot.turnAround()
- --robot.turnAround()
- --robot.turnRight()
- --move(x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement