Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require("robot")
- local computer = require("computer")
- local rEnergy = computer.maxEnergy() - computer.energy()
- local passable, state = robot.detect()
- local args = {...} -- ... gets the program's arguments somehow
- local rowsToDig = args[1] -- getting the first argument in the argument table
- local function digHollow3x3()
- while true do
- for i = 1, rowsToDig do
- if rEnergy < 200 then
- robot.select()
- robot.turnLeft()
- robot.place()
- robot.suck()
- os.sleep(20)
- robot.swing()
- robot.turnRight()
- end
- robot.detectDown()
- if state == "liquid" or "air" then robot.select() -- dev/ null
- robot.placeDown()
- end
- robot.select() -- rails
- robot.placeDown()
- robot.detect()
- if state == "solid" then robot.select() -- mining tool
- robot.swing() -- swing at block 2
- end
- robot.forward()
- robot.turnLeft() -- face left
- robot.detect() -- check for solid block
- if state == "solid" then robot.select()
- robot.swing() -- swing at block 1
- end
- robot.forward() -- under block 4
- robot.detectDown() -- detect under block 1
- if state == "liquid" or "air" then robot.select() -- dev/ null
- robot.placeDown()
- end
- robot.detect() -- detect left side of block 1
- if state == "liquid" or "air" then robot.select() -- dev/ null
- robot.place()
- end
- robot.turnAround() -- face right
- robot.forward() -- under block 5
- robot.detect()
- if state == "solid" then robot.select() -- mining tool
- robot.swing()-- swing at block 3
- end
- robot.forward() -- under block 6
- robot.detect() -- detect right side of block 3
- if state == "liquid" or "air" then robot.select() -- dev/ null
- robot.place()
- end
- robot.detectDown() -- detect under block block 3
- if state == "liquid" or "air" then robot.select() -- dev/ null
- robot.place()
- end
- robot.detectUp
- if state == "solid" then robot.select() -- mining tool
- robot.swing()-- swing at block 6
- end
- robot.up() -- under block 9
- robot.detect() -- detect block right of block 6
- if state == "liquid" or "air" then robot.select() -- dev/ null
- robot.place()
- end
- robot.turnAround() -- face left
- robot.detect()
- if state == "solid" then robot.select() -- mining tool
- robot.swing() -- swing at block 5
- end
- robot.forward() -- under block 8
- robot.detect()
- if state == "solid" then robot.select() -- mining tool
- robot.swing() -- swing at block 4
- end
- robot.forward() -- under block 7
- robot.detect() -- detect block at right of block 4
- if state == "liquid" or "air" then robot.select() -- dev/ null
- robot.place()
- end
- robot.detectUp()
- if state == "solid" then robot.select() -- mining tool
- robot.swing() -- swing at block 7
- 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() -- dev/ null
- robot.place()
- end
- robot.detectUp() -- detect block above block 7
- if state == "liquid" or "air" then robot.select() -- dev/null
- robot.placeUp()
- end
- robot.turnAround() -- face right
- robot.detect()
- if state == "solid" then robot.select() -- mining tool
- robot.swing() -- swing at block 8
- end
- robot.forward() -- at block 8 position
- robot.detectUp() -- detect block above block 8
- if state == "liquid" or "air" then robot.select()
- robot.placeUp()
- end
- robot.forward() -- at block 9 position
- robot.detectUp() -- detect block above block 9
- if state == "liquid" or "air" then robot.select()
- robot.placeUp()
- end
- robot.detect() -- detect block on the right of block 9
- if state == "liquid" or "air" then robot.select()
- robot.place()
- end
- robot.back()
- robot.turnLeft() -- face toward next layer
- robot.down(2)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement