Advertisement
SythsGod

Tunneling

Jul 1st, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. -- mining program
  2.  
  3. local currentPosition = vector.new(gps.locate(5))
  4. local startPos = vector.new(gps.locate(5))
  5.  
  6. function getPosition()
  7.     currentPosition = vector.new(gps.locate(5))
  8. end
  9.  
  10. function digAround()
  11.     for i = 0, 3, 1 do
  12.         turtle.dig()
  13.         turtle.turnRight()
  14.     end
  15. end
  16.  
  17. function moveUp()
  18.     while currentPosition.y < startPos.y do
  19.         turtle.up()
  20.         getPosition()
  21.     end
  22. end
  23.  
  24. function firstRun()
  25.     print("Going down!")
  26.  
  27.     while currentPosition.y > 13 do
  28.         print("Current Y position: " .. currentPosition.y)
  29.         turtle.digDown()
  30.         turtle.down()
  31.         print("Getting new position...")
  32.         getPosition()
  33.     end
  34. end
  35.  
  36. function secondRun()
  37.     while currentPosition.y > 3 do
  38.         print("Digging...")
  39.         digAround()
  40.         turtle.digDown()
  41.         if not turtle.down() then
  42.             break
  43.         end
  44.         getPosition()
  45.     end
  46. end
  47.  
  48. firstRun()
  49. print("We are at Y 13!")
  50. print("Initiating lower-dig protocol...")
  51. secondRun()
  52. print("Going back up!")
  53. moveUp()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement