Guest User

chunckminer

a guest
Oct 27th, 2012
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.89 KB | None | 0 0
  1. layer = 1
  2. line = 1
  3. torch = 1
  4. room = 0
  5.  
  6. function fuel()
  7.   if turtle.getFuelLevel() < 250 then
  8.     turtle.digUp()
  9.     turtle.select(13)
  10.     turtle.placeUp()
  11.     turtle.select(12)
  12.     turtle.dropDown()
  13.     turtle.suckUp()
  14.     turtle.refuel()
  15.     turtle.suckDown()
  16.     turtle.select(13)
  17.     turtle.digUp()
  18.     turtle.select(1)    
  19.   end
  20. end
  21.  
  22. function drop()
  23.   turtle.digUp()
  24.   turtle.select(14)
  25.   turtle.placeUp()
  26.   for i = 1,12 do
  27.     turtle.select(i)
  28.     turtle.dropUp()
  29.   end
  30.   turtle.select(14)
  31.   turtle.digUp()
  32.   turtle.select(1)
  33. end
  34.  
  35. function inv()
  36.   for i = 1,12 do
  37.     if turtle.getItemCount(i) == 0 then
  38.       room = room + 1
  39.     end
  40.   end
  41.  
  42.   if room == 0 then
  43.     drop()
  44.   else room = 0  
  45.   end
  46.  
  47. end
  48.  
  49. function forward()
  50.   while not turtle.forward() do
  51.     inv()
  52.     if not turtle.dig() then
  53.       turtle.attack()
  54.     end
  55.   end
  56. end
  57.  
  58. function up()
  59.   while not turtle.up() do
  60.     inv()
  61.     turtle.digUp()
  62.   end
  63. end
  64.  
  65. function down()
  66.   while not turtle.down() do
  67.     inv()
  68.     turtle.digDown()
  69.   end
  70. end
  71.  
  72. function updown()
  73.   inv()
  74.   turtle.digUp()
  75.   inv()
  76.   turtle.digDown()
  77. end
  78.  
  79. function left()
  80.   turtle.turnLeft()
  81.   forward()
  82.   turtle.turnLeft()
  83.   updown()
  84. end
  85.  
  86. function right()
  87.   turtle.turnRight()
  88.   forward()
  89.   turtle.turnRight()
  90.   updown()
  91. end
  92.  
  93. function deployAnchor()
  94.   forward()
  95.   inv()
  96.   turtle.digDown()
  97.   turtle.select(15)
  98.   turtle.placeDown()
  99.   turtle.select(1)
  100.   right()
  101.   forward()
  102.   updown()
  103. end
  104.  
  105. function grabAnchor()
  106.   turtle.select(15)
  107.   inv()
  108.   turtle.digDown()
  109.   turtle.select(1)
  110. end
  111.  
  112. function placeTorch()
  113.   down()
  114.   if turtle.detectDown() then
  115.       up()
  116.       turtle.select(16)
  117.       turtle.placeDown()
  118.       turtle.select(1)
  119.   else
  120.     up()
  121.   end    
  122. end
  123.  
  124. function goStart()
  125.   for i = 1,2 do
  126.     turtle.turnLeft()
  127.     for i = 1,6 do
  128.       forward()
  129.     end
  130.   end
  131.   turtle.turnLeft()
  132.   turtle.turnLeft()
  133.   if layer == 1 then
  134.     grabAnchor()
  135.   end
  136. end
  137.  
  138. function row()
  139.   for i = 1,6 do
  140.     forward()
  141.     updown()
  142.     torch = torch + 1
  143.     if torch == 4 and line == 4 and layer == 1 then
  144.       placeTorch()
  145.     end
  146.   end
  147.   torch = 1
  148.  
  149.   if line == 1 and layer == 1 then
  150.     deployAnchor()
  151.     line = line + 1
  152.   elseif line < 7 then
  153.     if (line % 2) == 0 then
  154.       left()
  155.       line = line + 1
  156.     else
  157.       right()
  158.       line = line + 1
  159.     end
  160.   else
  161.     goStart()
  162.     line = 1
  163.   end
  164. end
  165.  
  166. function chunck()
  167.   for i = 1,7 do
  168.     row()
  169.   end
  170.   layer = layer + 1
  171. end
  172.  
  173. function layerUp()
  174.   for i = 1,3 do
  175.     up()
  176.   end
  177.   inv()
  178.   turtle.digUp()
  179. end
  180.  
  181. while true do
  182.     fuel()
  183.     while layer ~= 4 do
  184.       chunck()
  185.       if layer ~= 4 then
  186.         layerUp()
  187.       else
  188.         inv()
  189.         turtle.digUp()
  190.         for i = 1,7 do
  191.           forward()
  192.         end
  193.         for i = 1,6 do
  194.           down()
  195.         end
  196.       end
  197.     end
  198. end
Advertisement
Add Comment
Please, Sign In to add comment