Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require("robot")
- local computer = require("computer")
- local sides = require("sides")
- local component = require("component")
- local c = component.crafting
- local inventory = component.inventory_controller
- local g = component.generator
- local passable, state = robot.detect() -- return values for robot.detect()
- local args = {...} -- ... gets the program's arguments somehow
- local rowsToDig = args[1] -- getting the first argument in the argument table
- local function checkEnergy()
- if computer.energy() <= 200 then
- robot.select(15)
- g.insert()
- robot.select(2)
- robot.drop()
- robot.select(3)
- robot.drop()
- robot.select(4)
- robot.drop()
- robot.select(5)
- robot.drop()
- robot.select(6)
- robot.drop()
- robot.select(7)
- robot.drop()
- robot.select(8)
- robot.drop()
- robot.select(9)
- robot.drop()
- robot.select(10)
- robot.drop()
- robot.select(11)
- robot.drop()
- robot.select(14)
- robot.turnLeft()
- robot.place()
- robot.select(15)
- inventory.suckFromSlot(3, 1)
- g.insert()
- inventory.suckFromSlot(3, 1)
- robot.select(2)
- robot.transferTo(14)
- os.sleep(20)
- robot.swing()
- robot.turnRight()
- os.sleep(60)
- until computer.energy() >= 201
- else computer.shutdown()
- end
- local function checkTool()
- if not robot.durability() <= 0.2 and robot.count(1) <= 0 then
- repeat
- robot.select(2)
- robot.drop()
- robot.select(3)
- robot.drop()
- robot.select(4)
- robot.drop()
- robot.select(5)
- robot.drop()
- robot.select(6)
- robot.drop()
- robot.select(7)
- robot.drop()
- robot.select(8)
- robot.drop()
- robot.select(9)
- robot.drop()
- robot.select(10)
- robot.drop()
- robot.select(11)
- robot.drop()
- robot.select(17)
- robot.transferTo(2)
- c.craft(1)
- robot.select(2)
- robot.transferTo(17)
- until robot.durability() == 1 or robot.count(1) <= 0 and robot.durability() >= 0.2
- else computer.shutdown()
- end
- local function digHollow3x3()
- for i = 1, rowsToDig do
- checkEnergy()
- checkTool()
- robot.detectDown()
- if state == "liquid" or "air" then robot.select(13) -- dev/ null
- robot.placeDown()
- end
- robot.select(4) -- rails
- robot.placeDown()
- robot.detect()
- if state == "solid" then robot.swing() -- swing at block 2
- checkTool()
- end
- robot.forward()
- robot.turnLeft() -- face left
- robot.detect() -- check for solid block
- if state == "solid" then robot.swing() -- swing at block 1
- checkTool()
- end
- robot.forward() -- under block 4
- robot.detectDown() -- detect under block 1
- if state == "liquid" or "air" then robot.select(13) -- dev/ null
- robot.placeDown()
- end
- robot.detect() -- detect left side of block 1
- if state == "liquid" or "air" then robot.select(13) -- dev/ null
- robot.place()
- end
- robot.turnAround() -- face right
- robot.forward() -- under block 5
- robot.detect()
- if state == "solid" then robot.swing()-- swing at block 3
- checkTool()
- end
- robot.forward() -- under block 6
- robot.detect() -- detect right side of block 3
- if state == "liquid" or "air" then robot.select(13) -- dev/ null
- robot.place()
- end
- robot.detectDown() -- detect under block block 3
- if state == "liquid" or "air" then robot.select(13) -- dev/ null
- robot.place()
- end
- robot.detectUp()
- if state == "solid" then robot.swing()-- swing at block 6
- checkTool()
- end
- robot.up() -- under block 9
- robot.detect() -- detect block right of block 6
- if state == "liquid" or "air" then robot.select(13) -- dev/ null
- robot.place()
- end
- robot.turnAround() -- face left
- robot.detect()
- if state == "solid" then robot.swing() -- swing at block 5
- checkTool()
- end
- robot.forward() -- under block 8
- robot.detect()
- if state == "solid" then robot.swing() -- swing at block 4
- checkTool()
- end
- robot.forward() -- under block 7
- robot.detect() -- detect block at right of block 4
- if state == "liquid" or "air" then robot.select(13) -- dev/ null
- robot.place()
- end
- robot.detectUp()
- if state == "solid" then robot.swing() -- swing at block 7
- checkTool()
- end
- robot.up() -- at block 7 position
- robot.detect() -- detect block on left side of block 7
- if state == "liquid" or "air" then robot.select(13) -- dev/ null
- robot.place()
- end
- robot.detectUp() -- detect block above block 7
- if state == "liquid" or "air" then robot.select(13) -- dev/null
- robot.placeUp()
- end
- robot.turnAround() -- face right
- robot.detect()
- if state == "solid" then robot.swing() -- swing at block 8
- checkTool()
- end
- robot.forward() -- at block 8 position
- robot.detectUp() -- detect block above block 8
- if state == "liquid" or "air" then robot.select(13)
- robot.placeUp()
- end
- robot.forward() -- at block 9 position
- robot.detectUp() -- detect block above block 9
- if state == "liquid" or "air" then robot.select(13)
- robot.placeUp()
- end
- robot.detect() -- detect block on the right of block 9
- if state == "liquid" or "air" then robot.select(13)
- robot.place()
- end
- robot.back()
- robot.turnLeft() -- face toward next layer
- robot.down(2)
- end
- digHollow3x3()
Add Comment
Please, Sign In to add comment