Advertisement
Guest User

strip.lua

a guest
Jan 19th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. local component = require("component")
  2. local robot = component.proxy(component.list("robot")())
  3.  
  4. local square = 5
  5. local depth = 0
  6. local good = true
  7.  
  8. function dumpInventory()
  9.   print("Inventory Full. Dumping to Chest")
  10.   robot.select(1)
  11.   robot.place(1)
  12.   for i = 2, 16 do
  13.     robot.select(i)
  14.     robot.drop(1)
  15.   end
  16.   robot.select(1)
  17.   robot.swing(1)
  18.   robot.select(2)
  19. end
  20.  
  21. function checkInventory()
  22.   if robot.space(16) < 64 then
  23.     dumpInventory()
  24.   end
  25. end
  26.  
  27. -- strip mine down
  28. while good do
  29. for i=1, square do
  30.   for j=1, square-1 do
  31.     robot.swing(3)
  32.     robot.move(3)
  33.  
  34.     checkInventory() -- Check every swing to make sure nothing is lost
  35.   end
  36.  
  37.   robot.turn(i % 2 == 0)
  38.   if i < 5 then
  39.     robot.swing(3)
  40.     robot.move(3)
  41.   end
  42.   robot.turn(i % 2 == 0)
  43.   end
  44.   robot.swing(0)
  45.   if robot.detect(0) then -- if it hit bedrock
  46.     good = false
  47.   else
  48.     robot.move(0)
  49.     depth = depth+1
  50.   end
  51. end
  52.  
  53. if depth % 2 == 0 then -- If on the opposite corner
  54.   for i = 1, square-1 do
  55.     robot.move(3)
  56.   end
  57.   robot.turn(false)
  58.   for i = 1, square-1 do
  59.     robot.move(3)
  60.   end
  61. end
  62.  
  63. -- Move back up
  64. for i = 1, depth do
  65.   robot.move(1)
  66. end
  67. robot.turn(false) -- Final left turn to face original
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement