JMANN2400

Quarry[NoFuel]

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