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(5)
- robot.drop()
- robot.select(6)
- robot.drop()
- robot.select(7)
- 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.swing()
- robot.select(2)
- robot.transferTo(14)
- os.sleep(20)
- robot.turnRight()
- os.sleep(60)
- end
- end
- local function placeRails()
- local hasRails = inventory.getStackInInternalSlot(4)
- robot.select(4)
- if robot.count() <=2 then
- robot.select(8)
- robot.turnRight()
- robot.place()
- robot.select(2)
- robot.drop()
- robot.select(3)
- robot.drop()
- robot.select(5)
- robot.drop()
- robot.select(6)
- robot.drop()
- robot.select(7)
- robot.drop()
- robot.select(9)
- robot.drop()
- robot.select(10)
- robot.drop()
- robot.select(11)
- robot.drop()
- for slot = 1, inventory.getInventorySize(3) do
- if hasRails = inventory.getStackInSlot(slot) then
- repeat
- inventory.suckFromSlot(3, slot)
- until robot.count(4) >= 3
- return slot
- robot.swing()
- robot.select(2)
- robot.transferTo(8)
- robot.select(4)
- robot.turnLeft()
- end
- end
- end
- robot.turnAround()
- robot.place()
- robot.turnAround()
- end
- --[[local function checkTool()
- if not robot.durability(0.2) and robot.count(1) <= 0 then
- 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)
- end
- 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
- placeRails()
- robot.detect()
- if state == "solid" then robot.swing() -- swing at block 2
- -- checkTool()
- end
- repeat
- robot.detect()
- if state == "solid" then robot.swing()
- until state == "liquid" or "air" then robot.forward() -- moving forward
- end
- robot.turnLeft() -- face left
- robot.detect() -- check for solid block
- if state == "solid" then robot.swing() -- swing at block 1
- end
- -- checkTool()
- repeat
- robot.detect()
- if state == "solid" then robot.swing()
- until state == "liquid" or "air" then robot.forward() -- moving forward under block 4
- end
- 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
- repeat
- robot.detect()
- if state == "solid" then robot.swing()
- until state == "liquid" or "air" then robot.forward() -- moving forward under block 5
- end
- robot.detect()
- if state == "solid" then robot.swing()-- swing at block 3
- end
- -- checkTool()
- repeat
- robot.detect()
- if state == "solid" then robot.swing()
- until state == "liquid" or "air" then robot.forward() -- moving forward under block 6
- end
- 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.swingUp()-- swing at block 6
- end
- -- checkTool()
- repeat
- robot.detectUp()
- if state == "solid" then robot.swing()
- until state == "liquid" or "air" then robot.up() -- moving up under block 9
- end
- 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
- repeat
- robot.detect()
- if state == "solid" then robot.swing()
- until state == "liquid" or "air" then robot.forward() -- moving forward under block 8
- end
- robot.detect()
- if state == "solid" then robot.swing() -- swing at block 4
- end
- -- checkTool()
- repeat
- robot.detect()
- if state == "solid" then robot.swing()
- until state == "liquid" or "air" then robot.forward() -- moving forward under block 7
- end
- 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.swingUp() -- swing at block 7
- checkTool()
- end
- repeat
- robot.detectUp()
- if state == "solid" then robot.swing()
- until state == "liquid" or "air" then robot.up() -- moving up at block 7 position
- end
- 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
- repeat
- robot.detect()
- if state == "solid" then robot.swing()
- until state == "liquid" or "air" then robot.forward() -- moving forward at block 8 position
- end
- robot.detectUp() -- detect block above block 8
- if state == "liquid" or "air" then robot.select(13)
- robot.placeUp()
- end
- robot.detect()
- if state == "solid" then robot.swing()
- end
- repeat
- robot.detect()
- if state == "solid" then robot.swing()
- until state == "liquid" or "air" then robot.forward() -- moving forward at block 9 position
- end
- 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.turnAround()
- repeat
- robot.detect()
- if state == "solid" then robot.swing()
- until state == "liquid" or "air" then robot.forward() -- moving forward
- end
- robot.turnRight() -- face toward next layer
- repeat
- robot.detectDown()
- if state == "solid" then robot.swing()
- until state == "liquid" or "air" then robot.down()
- end
- repeat
- robot.detectDown()
- if state == "solid" then robot.swing()
- until state == "liquid" or "air" then robot.down()
- end
- digHollow3x3()
Add Comment
Please, Sign In to add comment