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 inventory_controller = require("inventory_controller")
- local c = component.crafting
- local inventory = component.inventory_controller
- local rEnergy = computer.maxEnergy() - computer.energy() -- Remaining Robot Energy
- 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 checkTool()
- if not robot.durability() <= 0.2 and if 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)
- until robot.durability() == 1 or robot.count(1) == 0
- else computer.shutdown()
- end
- end
- -- else
- -- Can't re-equip autonomously, wait for player to give us a tool.
- -- io.write("I need a new tool.\n")
- -- computer.shutdown()
- -- repeat
- -- until robot.durability()
- -- end
- -- end
- -- end
- local function digHollow3x3()
- for i = 1, rowsToDig do
- checkTool()
- end
- if rEnergy < 200 then
- robot.select(14)
- robot.turnLeft()
- robot.place()
- robot.select(15)
- inventory.suckFromSlot(3, 1)
- robot.select(3)
- inventory.suckFromSlot(3, 2)
- os.sleep(20)
- robot.swing()
- robot.turnRight()
- os.sleep(10)
- end
- robot.detectDown()
- if state == "liquid" or "air" then robot.select(13) -- dev/ null
- robot.placeDown()
- end
- robot.select() -- rails
- robot.placeDown()
- robot.detect()
- if state == "solid" then robot.swing() -- swing at block 2
- end
- checkTool()
- end
- robot.forward()
- robot.turnLeft() -- face left
- robot.detect() -- check for solid block
- if state == "solid" then robot.swing() -- swing at block 1
- end
- 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
- end
- 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
- end
- 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
- end
- checkTool()
- end
- robot.forward() -- under block 8
- robot.detect()
- if state == "solid" then robot.swing() -- swing at block 4
- end
- 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
- end
- 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
- end
- 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
- end
- end
- digHollow3x3()
Add Comment
Please, Sign In to add comment