Advertisement
tiaggo11

strip_torch_chest

Jul 22nd, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.32 KB | None | 0 0
  1. print("Arm length: ")
  2. local armlength = read()
  3.  
  4. print("Iteration: ")
  5. local iteration = read()
  6.  
  7. print("Torch Slot: ")
  8. local torchslot = tonumber(read())
  9.  
  10. print("WiFi Chest Slot: ")
  11. local chestslot = tonumber(read())
  12.  
  13. function fallingBlocksFront()
  14.     while turtle.detect(gravel) == true do
  15.         turtle.dig()
  16.     end
  17.     while turtle.detect(sand) == true do
  18.         turtle.dig()
  19.     end
  20. end
  21.  
  22. function fallingBlocksUpside()
  23.     while turtle.detectUp(gravel) == true do
  24.         turtle.digUp()
  25.     end
  26.     while turtle.detectUp(sand) == true do
  27.         turtle.digUp()
  28.     end
  29. end
  30.  
  31. function noFrontLeft(goback)
  32.    
  33.     if turtle.detect() == false then
  34.         backLeft(goback)
  35.         return true
  36.     end
  37.     return false
  38. end
  39.  
  40. function noFrontRight(goback)
  41.    
  42.     if turtle.detect() == false then
  43.         backRight(goback)
  44.         return true
  45.        
  46.     end
  47.     return false
  48. end
  49.  
  50. function noGround()
  51.     if turtle.detectDown() == false then
  52.         for i = 1, 16 do
  53.             turtle.select(i)
  54.             local data = turtle.getItemDetail()
  55.  
  56.             if data.name == "minecraft:cobblestone" then
  57.                 turtle.placeDown()
  58.                 break
  59.             end
  60.            
  61.         end
  62.     end
  63. end
  64.  
  65. function checkFuel()
  66.     local fuel = turtle.getFuelLevel()
  67.  
  68.     if fuel < 30 then
  69.         for i = 1, 16 do
  70.             turtle.select(i)
  71.             local data = turtle.getItemDetail()
  72.             local count = turtle.getItemCount()
  73.            
  74.             if count > 0 then
  75.                 if data.name == "minecraft:coal" then
  76.                     turtle.refuel()    
  77.                     break
  78.                 end
  79.             end
  80.         end
  81.     end
  82.  
  83.     local fuel = turtle.getFuelLevel()
  84.  
  85.     if fuel < 30 then
  86.         print("Not enough fuel")
  87.         error()
  88.     end
  89.    
  90. end
  91.  
  92. function tryForward()
  93.     while not turtle.forward() do
  94.         turtle.attack()
  95.         sleep(1)
  96.  
  97.     end
  98. end
  99.  
  100. function tunnleLeft(length)
  101.     turtle.turnLeft()
  102.     for i = 0, length-1 do
  103.         if not(noFrontLeft(i)) then
  104.             turtle.dig()
  105.             fallingBlocksFront()
  106.             tryForward()
  107.             turtle.digUp()
  108.             fallingBlocksUpside()
  109.             noGround()
  110.         else
  111.             break
  112.         end
  113.         if i == length-1 then
  114.             backLeft(length)
  115.     end
  116.     end
  117.    
  118. end
  119.  
  120. function tunnleRight(length)
  121.     turtle.turnRight()
  122.     for i = 0, length-1 do
  123.         if not(noFrontRight(i)) then
  124.             turtle.dig()
  125.             fallingBlocksFront()
  126.             tryForward()
  127.             turtle.digUp()
  128.             fallingBlocksUpside()
  129.             noGround()
  130.         else
  131.             break
  132.         end
  133.         if i == length-1 then
  134.             backRight(length)
  135.         end
  136.     end
  137.    
  138. end
  139.  
  140.  
  141. function tunnle(length)
  142.     for i = 0, length-1 do
  143.         turtle.dig()
  144.         fallingBlocksFront()
  145.         tryForward()
  146.         turtle.digUp()
  147.         fallingBlocksUpside()
  148.         noGround()
  149.     end
  150. end
  151.  
  152. function backLeft(length)
  153.     turtle.turnLeft()
  154.     turtle.turnLeft()
  155.    
  156.     for i = 1, length do
  157.         tryForward()
  158.        
  159.     end
  160.     turtle.turnLeft()
  161. end
  162.  
  163. function backRight(length)
  164.     turtle.turnRight()
  165.     turtle.turnRight()
  166.    
  167.     for i = 1, length do
  168.         tryForward()
  169.        
  170.     end
  171.     turtle.turnRight()
  172. end
  173.  
  174. function torch(slot)
  175.     turtle.select(slot)
  176.     local data = turtle.getItemCount()
  177.     if data > 0 then
  178.         turtle.turnLeft()
  179.         turtle.turnLeft()
  180.         turtle.place()
  181.         turtle.turnLeft()
  182.         turtle.turnLeft()
  183.     end
  184. end
  185.  
  186. function chest()
  187.     turtle.turnLeft()
  188.     turtle.turnLeft()
  189.     turtle.select(chestslot)
  190.     turtle.place()
  191.     for i = 1, 16 do
  192.         if not (i == torchslot or i == chestslot) then
  193.             turtle.select(i)
  194.             local count = turtle.getItemCount()
  195.             if count > 0 then
  196.                 turtle.drop(count)
  197.             end
  198.         end
  199.     end
  200.     turtle.select(chestslot)
  201.     turtle.dig()
  202.     turtle.turnLeft()
  203.     turtle.turnLeft()
  204. end
  205.  
  206. for i = 0, iteration do
  207.     checkFuel()
  208.     tunnle(3)
  209.  
  210.     if(i%15) == 0 then
  211.         chest()
  212.     end
  213.     if (i%3) == 0 then
  214.        
  215.         torch(torchslot)
  216.  
  217.     end
  218.  
  219.     tunnleLeft(armlength)
  220.     tunnleRight(armlength)
  221. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement