Advertisement
fatboychummy

Quarry3x3

Oct 10th, 2016
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.36 KB | None | 0 0
  1. --Quarry3x3 by Fatboychummy (Or Fatmanchummy; depends where you look).
  2. --Changelog and stuff can be found online on the computercraft forums.  (No link yet) (Find it under the Turtle Programs subforum)
  3.  
  4.  
  5. term.clear()
  6. term.setCursorPos(1,1)
  7. print("Starting up.")
  8.  
  9. turtle.select(16)
  10. if turtle.refuel(0) == true then
  11.  
  12.   turtle.refuel(3)
  13.  
  14. end
  15.  
  16.  
  17. function Start()
  18.   print("Detecting surroundings")
  19.  
  20.  
  21.   local std = turtle.detectDown()
  22.   local stf = turtle.detect()
  23.   turtle.turnRight()
  24.   local str = turtle.detect()
  25.   turtle.turnRight()
  26.   local stb = turtle.detect()
  27.   turtle.turnRight()
  28.   local stl = turtle.detect()
  29.   turtle.turnRight()
  30.  
  31.   if std == true then
  32.  
  33.     print("First detected: beneath")
  34.     Ground()
  35.  
  36.   elseif stf == true then
  37.  
  38.     print("First detected: Forwards")
  39.     turtle.dig()
  40.     turtle.forward()
  41.     Ground()
  42.  
  43.   elseif str == true then
  44.  
  45.     print("First detected: Right")
  46.     turtle.turnRight()
  47.     turtle.dig()
  48.     turtle.forward()
  49.     Ground()
  50.  
  51.   elseif stb == true then
  52.  
  53.     print("First detected: Rear")
  54.     turtle.turnRight()
  55.     turtle.turnRight()
  56.     turtle.dig()
  57.     turtle.forward()
  58.     Ground()
  59.  
  60.   elseif stl == true then
  61.  
  62.     print("First detected: Left")
  63.     turtle.turnLeft()
  64.     turtle.dig()
  65.     turtle.forward()
  66.     Ground()
  67.  
  68.   else
  69.  
  70.     print("Nothing detected.  Moving downwards until something is detected.")
  71.     findGround()
  72.   end
  73. end
  74.  
  75. function findGround()
  76.  
  77.   while turtle.detectDown() == false do
  78.  
  79.     turtle.down()
  80.  
  81.   end
  82.  
  83.   Ground()
  84.  
  85. end
  86.  
  87.  
  88. function Ground()
  89.  
  90.   while true do
  91. local derp = turtle.getFuelLevel()
  92.  
  93.  
  94. print(derp)
  95.  
  96. turtle.select(16)
  97. wat = turtle.getFuelLevel()
  98. if wat < 300 then
  99.  
  100.   if turtle.refuel(0) == true then
  101.  
  102.     while wat < 3000 do
  103.    
  104.       turtle.refuel(1)
  105.       os.sleep(0.1)
  106.       wat = turtle.getFuelLevel()
  107.       print("current fuel: ", wat)
  108.    
  109.     end
  110.  
  111.   end
  112.  
  113. end
  114.  
  115.   print("Moving down 3 blocks")
  116.     for i = 1,3 do
  117.  
  118.       if turtle.detectDown() == true then
  119.  
  120.         turtle.digDown()
  121.         turtle.down()
  122.        
  123.       else
  124.      
  125.         turtle.down()
  126.  
  127.       end
  128.      
  129.     end
  130.    
  131.     print("Beginning first section (1/5)")
  132.     turtle.digDown()
  133.     turtle.dig()
  134.     turtle.forward()
  135.     turtle.dig()
  136.     turtle.digDown()
  137.     turtle.digUp()
  138.     turtle.turnRight()
  139.     turtle.dig()
  140.     turtle.turnLeft()
  141.     turtle.forward()
  142.     turtle.turnRight()
  143.    
  144.     print("Beginning second section (2/5)")
  145.    
  146.     for i = 1,2 do
  147.    
  148.       turtle.dig()
  149.       turtle.digUp()
  150.       turtle.digDown()
  151.       turtle.forward()
  152.    
  153.     end
  154.     print("Beginning third section (3/5)")
  155.     turtle.turnRight()
  156.     for i = 1,2 do
  157.    
  158.       turtle.dig()
  159.       turtle.digUp()
  160.       turtle.digDown()
  161.       turtle.forward()
  162.    
  163.     end
  164.    
  165.     print("Beginning fourth section (4/5)")
  166.     turtle.turnRight()
  167.     for i = 1,2 do
  168.    
  169.       turtle.dig()
  170.       turtle.digUp()
  171.       turtle.digDown()
  172.       turtle.forward()
  173.    
  174.     end
  175.    
  176.     print("Finished this section, removing center.")
  177.    
  178.    
  179.    
  180.    
  181.     turtle.turnRight()
  182.     turtle.forward()
  183.     turtle.turnRight()
  184.     turtle.up()
  185.     turtle.dig()
  186.     turtle.down()
  187.     turtle.down()
  188.     turtle.dig()
  189.     turtle.up()
  190.     turtle.back()
  191.     turtle.turnLeft()
  192.     turtle.back()
  193.    
  194.    
  195.    
  196.   end
  197.  
  198. end
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205. Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement