Advertisement
Guest User

Untitled

a guest
Apr 29th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.53 KB | None | 0 0
  1. local robot = require("robot")
  2. local computer = require("computer")
  3.  
  4. local rEnergy = computer.maxEnergy() - computer.energy()
  5. local passable, state = robot.detect()
  6. local args = {...} -- ... gets the program's arguments somehow
  7. local rowsToDig = args[1] -- getting the first argument in the argument table
  8.  
  9.  
  10. local function digHollow3x3()
  11.  
  12.   while true do
  13.       for i = 1, rowsToDig do
  14.         if rEnergy < 200  then
  15.             robot.select()
  16.             robot.turnLeft()
  17.             robot.place()
  18.             robot.suck()
  19.             os.sleep(20)
  20.             robot.swing()
  21.             robot.turnRight()
  22.         end
  23.           robot.detectDown()
  24.         if state == "liquid" or "air" then robot.select() -- dev/ null
  25.           robot.placeDown()
  26.         end
  27.           robot.select() -- rails
  28.           robot.placeDown()
  29.           robot.detect()
  30.         if state == "solid" then robot.select() -- mining tool
  31.           robot.swing() -- swing at block 2
  32.         end
  33.           robot.forward()      
  34.           robot.turnLeft() -- face left
  35.           robot.detect() -- check for solid block
  36.         if state == "solid" then robot.select()
  37.           robot.swing() -- swing at block 1
  38.         end
  39.           robot.forward() -- under block 4
  40.           robot.detectDown() -- detect under block 1
  41.         if state == "liquid" or "air" then robot.select() -- dev/ null
  42.           robot.placeDown()
  43.         end
  44.           robot.detect() -- detect left side of block 1
  45.         if state == "liquid" or "air" then robot.select() -- dev/ null
  46.           robot.place()
  47.         end
  48.           robot.turnAround() -- face right
  49.           robot.forward() -- under block 5
  50.           robot.detect()
  51.         if state == "solid" then robot.select() -- mining tool
  52.           robot.swing()-- swing at block 3
  53.         end
  54.           robot.forward() -- under block 6
  55.           robot.detect() -- detect right side of block 3
  56.         if state == "liquid" or "air" then robot.select() -- dev/ null
  57.           robot.place()
  58.         end
  59.           robot.detectDown() -- detect under block block 3
  60.         if state == "liquid" or "air" then robot.select() -- dev/ null
  61.           robot.place()
  62.         end
  63.           robot.detectUp
  64.         if state == "solid" then robot.select() -- mining tool
  65.           robot.swing()-- swing at block 6
  66.         end
  67.           robot.up() -- under block 9
  68.           robot.detect() -- detect block right of block 6
  69.         if state == "liquid" or "air" then robot.select() -- dev/ null
  70.           robot.place()
  71.         end
  72.           robot.turnAround() -- face left
  73.           robot.detect()
  74.         if state == "solid" then robot.select() -- mining tool
  75.           robot.swing() -- swing at block 5
  76.         end
  77.           robot.forward() -- under block 8
  78.           robot.detect()
  79.         if state == "solid" then robot.select() -- mining tool
  80.           robot.swing()          -- swing at block 4
  81.         end
  82.           robot.forward() -- under block 7
  83.           robot.detect() -- detect block at right of block 4
  84.         if state == "liquid" or "air" then robot.select() -- dev/ null
  85.           robot.place()
  86.         end
  87.           robot.detectUp()
  88.         if state == "solid" then robot.select() -- mining tool
  89.           robot.swing() -- swing at block 7
  90.         end
  91.           robot.up() -- at block 7 position
  92.           robot.detect() -- detect block on left side of block 7
  93.         if state == "liquid" or "air" then robot.select() -- dev/ null
  94.           robot.place()
  95.         end
  96.           robot.detectUp() -- detect block above block 7
  97.         if state == "liquid" or "air" then robot.select() -- dev/null
  98.           robot.placeUp()
  99.         end
  100.           robot.turnAround() -- face right    
  101.           robot.detect()
  102.         if state == "solid" then robot.select() -- mining tool
  103.           robot.swing() -- swing at block 8
  104.         end
  105.           robot.forward() -- at block 8 position
  106.           robot.detectUp() -- detect block above block 8
  107.         if state == "liquid" or "air" then robot.select()
  108.           robot.placeUp()
  109.         end
  110.           robot.forward() -- at block 9 position
  111.           robot.detectUp() -- detect block above block 9
  112.         if state == "liquid" or "air" then robot.select()
  113.           robot.placeUp()
  114.         end
  115.           robot.detect() -- detect block on the right of block 9
  116.         if state == "liquid" or "air" then robot.select()
  117.           robot.place()
  118.         end
  119.           robot.back()
  120.           robot.turnLeft() -- face toward next layer
  121.           robot.down(2)
  122.         end
  123.     end
  124. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement