Advertisement
JMANN2400

Quarry

Jul 31st, 2017
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.75 KB | None | 0 0
  1.  
  2.  
  3. n = 0
  4.  
  5. x = 0
  6.  
  7. y = 0
  8.  
  9. z = 0
  10.  
  11. function getCount()
  12.     c = 0
  13.     for i = 2, 15, 1 do
  14.         c = c + turtle.getItemCount(i)
  15.     end
  16.     return c
  17. end
  18.  
  19. function chest()
  20.     turtle.digUp()
  21.     turtle.select(1)
  22.     turtle.placeUp()
  23.     for a = 2,16,1 do
  24.         turtle.select(a)
  25.         turtle.dropUp()
  26.     end
  27.     n = 0
  28.     turtle.select(1)
  29. end
  30.  
  31. function printCoords()
  32.     print("x = ", x)
  33.     print("y = ", y)
  34.     print("z = ", z)
  35. end
  36.  
  37. function refuel()
  38.     turtle.select(16)
  39.     turtle.refuel()
  40.     turtle.select(1)
  41. end
  42.  
  43. function mine()
  44.     while y < h do
  45.         turtle.digDown()
  46.         if turtle.down() then
  47.             y = y + 1
  48.             printCoords()
  49.         end
  50.         while z < l - 2 do
  51.             if turtle.forward() then
  52.                 z = z + 1
  53.                 printCoords()
  54.             end
  55.             turtle.dig()
  56.             getCount()
  57.             if c > 512 then
  58.                 chest()
  59.             end
  60.             print(c)
  61.             refuel()
  62.             print("Fuel level = ", turtle.getFuelLevel())
  63.         end
  64.         while z > 0 do
  65.             if turtle.back() then
  66.                 z = z - 1
  67.                 printCoords()
  68.             end
  69.         end
  70.         while x < w - 1 do
  71.             if x < w - 1 then
  72.                 turtle.turnRight()
  73.                 turtle.dig()
  74.                 if turtle.forward() then
  75.                     x = x + 1
  76.                     printCoords()
  77.                 end
  78.                 turtle.turnLeft()
  79.             end
  80.             turtle.dig()
  81.             while z < l - 2 do
  82.                 if turtle.forward() then
  83.                     z = z + 1
  84.                     printCoords()
  85.                 end
  86.                 turtle.dig()
  87.                 getCount()
  88.                 if c > 512 then
  89.                     chest()
  90.                 end
  91.                 print(c)
  92.                 refuel()
  93.                 print("Fuel level = ", turtle.getFuelLevel())
  94.             end
  95.             while z > 0 do
  96.                 if turtle.back() then
  97.                     z = z - 1
  98.                     printCoords()
  99.                 end
  100.             end
  101.         end
  102.         turtle.turnLeft()
  103.         while x > 0 do
  104.             if turtle.forward() then
  105.                 x = x - 1
  106.                 printCoords()
  107.             end
  108.         end
  109.         turtle.turnRight()
  110.     end
  111.     while y > 0 do
  112.         if turtle.up() then
  113.             y = y - 1
  114.             printCoords()
  115.         end
  116.     end
  117. end
  118.  
  119.  
  120.  
  121. print("+-------------------------------------+")
  122. print("| Mega Quarry                         |")
  123. print("+-------------------------------------+")
  124. print("| Slot 16: Fuel                       |")
  125. print("| Slot 1: Chests                      |")
  126. print("+-------------------------------------+")
  127. print("| Place turtle at bottom left of      |")
  128. print("| quarry. Insert fuel. Specify        |")
  129. print("| dimensions. Press enter to start.   |")
  130. print("+-------------------------------------+")
  131. read()
  132. print("+-------------------------------------+")
  133. print("| Quarry length = ?                   |")
  134. print("+-------------------------------------+")
  135. l = tonumber(read())
  136. print("+-------------------------------------+")
  137. print("| Quarry width = ?                   |")
  138. print("+-------------------------------------+")
  139. w = tonumber(read())
  140. print("+-------------------------------------+")
  141. print("| Quarry height = ?                   |")
  142. print("+-------------------------------------+")
  143. h = tonumber(read())
  144.  
  145. refuel()
  146.  
  147.  
  148.  
  149. mine()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement