TheMudkip

TurtleChunk

Apr 9th, 2023 (edited)
865
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.46 KB | None | 0 0
  1. local l = 0
  2. local currentLayer = 0
  3. local size = 0
  4.  
  5.  
  6.  
  7. function fuelcheck(y)
  8.     local level = turtle.getFuelLevel()
  9.     if (level < 256 * y + 16)
  10.     then
  11.       write("There is not enough fuel")
  12.       os.shutdown()
  13.     else
  14.       write("There will be "..level - 256 * y.." fuel left")
  15.     end
  16. end
  17.  
  18. function layer()
  19.     turtle.digDown()
  20.     turtle.down()
  21.     currentLayer = currentLayer + 1
  22.     for i = 1, size, 1 do
  23.         for j = 1, size, 1 do
  24.             turtle.dig()
  25.             turtle.forward()
  26.         end
  27.  
  28.         if(i % 2 == 0)
  29.         then
  30.             turtle.turnLeft()
  31.             turtle.dig()
  32.             turtle.forward()
  33.             turtle.turnLeft()
  34.         else
  35.             turtle.turnRight()
  36.             turtle.dig()
  37.             turtle.forward()
  38.             turtle.turnRight()
  39.         end
  40.  
  41.     end
  42. end
  43.  
  44.  
  45. function initialchestDeposit()
  46. turtle.select(1)
  47. turtle.placeUp()
  48.     local s = 1
  49.         for i = 1, 15, 1 do
  50.             s = s + 1
  51.             turtle.select(s)
  52.             turtle.dropUp()
  53.         end
  54. end
  55.  
  56. function invCheck()
  57.     local s = 1
  58.     for i = 1, 15, 1 do
  59.         s = s + 1
  60.         turtle.select(s)
  61.         local data = turtle.getItemDetail()
  62.         if data
  63.         then
  64.             turtle.down()
  65.             deposit()
  66.             l = l - 1
  67.         end
  68.     end
  69. end
  70.  
  71. function chestDeposit()
  72.     l = 0
  73.     for i = 1, currentLayer - 1, 1 do
  74.         turtle.up()
  75.         l = l + 1
  76.     end
  77.     local s = 1
  78.     for i = 1, 15, 1 do
  79.         s = s + 1
  80.         turtle.select(s)
  81.         turtle.dropUp()
  82.     end
  83.     invCheck()
  84.     for i = 1, l, 1 do
  85.         turtle.down()
  86.     end
  87. end
  88.  
  89.  
  90.  
  91.  
  92. function deposit()
  93.     turtle.select(1)
  94.     turtle.placeUp()
  95.     local s = 1
  96.         for i = 1, 15, 1 do
  97.             s = s + 1
  98.             turtle.select(s)
  99.             turtle.dropUp()
  100.         end  
  101. end
  102.  
  103. function startPosition()
  104.     turtle.turnRight()
  105.         for i = 1, size, 1 do
  106.             turtle.forward()
  107.         end
  108.     turtle.turnRight()
  109. end
  110.  
  111. function chunk(y)
  112.     for i = 1, y, 1 do
  113.         layer()
  114.         startPosition()
  115.         print(currentLayer)
  116.         if (currentLayer == 1)
  117.         then
  118.             initialchestDeposit()
  119.         else
  120.             chestDeposit()
  121.         end
  122.     end
  123. end
  124.  
  125. write("How Many Layers to Remove?")
  126. local y = read()
  127. local x = y
  128. write("Enter Size\n")
  129. size = read()
  130. size = size - 1
  131. fuelcheck(y)
  132. print("Removing "..y.." Layers ...")
  133. chunk(y)
Advertisement
Add Comment
Please, Sign In to add comment