Advertisement
Shippeyy

MiningTurtle mining script

Oct 13th, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.29 KB | None | 0 0
  1. function main()
  2.    
  3.     checkForGravel("forward")
  4.     turtle.dig()
  5.     turtle.forward()
  6.  
  7.     checkForGravel("up")
  8.     turtle.digUp()
  9.  
  10.     turtle.digDown()
  11.  
  12.     setTorch()
  13.  
  14.     local counter = 0
  15.     while counter < 10
  16.     do
  17.         digLeft()
  18.         digRight()
  19.         nextRow()
  20.  
  21.         counter = counter + 1
  22.     end
  23. end
  24.  
  25. function nextRow()
  26.  
  27.     turtle.checkForGravel("forward")
  28.     turtle.dig()
  29.     turtle.forward()
  30.    
  31.     turtle.checkForGravel("forward")
  32.     turtle.dig()
  33.     turtle.forward()
  34.  
  35.     setTorch()
  36.    
  37. end
  38.  
  39. function checkForGravel(direction)
  40.  
  41.     if direction == "up" then
  42.         if turtle.inspectUp() == 13
  43.         then
  44.             reactToGravel(direction)
  45.         end
  46.     else
  47.         if direction == "forward"
  48.         then
  49.             if turtle.inspect() == 13
  50.             then
  51.                 reactToGravel(direction)
  52.             end
  53.         end
  54.     end
  55. end
  56.  
  57. function reactToGravel(direction)
  58.  
  59.     if direction == "up" then
  60.         turtle.digUp()
  61.         checkForGravel("up")
  62.     end
  63.  
  64.     if direction == "forward" then
  65.         turtle.dig()
  66.         checkForGravel("forward")
  67.     end
  68.    
  69. end
  70.  
  71. function setTorch()
  72.  
  73.     turtle.select(1)
  74.     turtle.placeDown()
  75.    
  76. end
  77.  
  78. function digLeft()
  79.    
  80.     turtle.turnLeft()
  81.     local counter = 0
  82.    
  83.     while counter < 7
  84.     do
  85.         turtle.dig()
  86.         checkForGravel("forward")
  87.         turtle.forward()
  88.         turtle.digUp()
  89.         turtle.digDown()
  90.         checkForGravel("up")
  91.  
  92.         counter = counter + 1
  93.     end
  94.  
  95.     turtle.turnLeft()
  96.     turtle.turnLeft()
  97.  
  98.     turtle.down()
  99.  
  100.     while counter >= -1
  101.     do
  102.         if turtle.detectDown() == false then
  103.             turtle.select(2)
  104.             turtle.placeDown()
  105.             turtle.forward()
  106.         end
  107.  
  108.         counter = counter - 1
  109.  
  110.     end
  111.  
  112.     turtle.up()
  113.     turtle.forward()
  114.     turtle.turnLeft()
  115. end
  116.  
  117. function digRight()
  118.  
  119.     turtle.turnRight()
  120.     local counter = 0
  121.    
  122.     while counter < 7
  123.     do
  124.         turtle.dig()
  125.         checkForGravel("forward")
  126.         turtle.forward()
  127.         turtle.digUp()
  128.         turtle.digDown()
  129.         checkForGravel("up")
  130.  
  131.         counter = counter + 1
  132.     end
  133.  
  134.     turtle.turnRight()
  135.     turtle.turnRight()
  136.  
  137.     turtle.down()
  138.  
  139.     while counter >= -1
  140.     do
  141.         if turtle.detectDown() == false
  142.         then
  143.             turtle.select(2)
  144.             turtle.placeDown()
  145.             turtle.forward()
  146.         end
  147.  
  148.         counter = counter - 1
  149.  
  150.     end
  151.  
  152.     turtle.up()
  153.     turtle.forward()
  154.     turtle.turnRight()
  155.  
  156. end
  157.  
  158. function checkStorage()
  159.  
  160.     local counter = 1
  161.  
  162.     while counter <= 16
  163.     do
  164.         if turtle.getItemCount(counter) < 64
  165.         then
  166.             return true
  167.         end
  168.  
  169.         counter = counter + 1
  170.     end
  171. end
  172.  
  173. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement