Advertisement
Proaxel

StripMineV2

May 29th, 2020
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.72 KB | None | 0 0
  1. args = {...}
  2. dist = args[1]
  3. run = true
  4. torchDistance = 1
  5. currentDistance = 0
  6. width = 1
  7. placeTorches = true
  8.  
  9. turtle.select(14)
  10. turtle.refuel()
  11. turtle.select(1)
  12.  
  13. print("Welcome! Current fuel: ", turtle.getFuelLevel())
  14. print("Enter the distance as an integer...")
  15. maxDistance = io.read()
  16. maxDistance = tonumber(maxDistance)
  17. print("Enter torch distance as an integer...")
  18. maxTorchDistance = io.read()
  19. maxTorchDistance = tonumber(maxTorchDistance)
  20. print("Enter width as an integer...")
  21. maxWidth = io.read()
  22. maxWidth = tonumber(maxWidth)
  23.  
  24.  
  25. if maxTorchDistance == 0 then
  26.     print("Okay, I won't place torches.")
  27.     placeTorches = false
  28. end
  29.  
  30. function placeTorch()
  31.     if turtle.getItemCount(15) > 0 then
  32.             if torchDistance >= maxTorchDistance then
  33.                 print("Setting Torch")
  34.                 turtle.select(15)
  35.                 print(turtle.place())
  36.                 turtle.select(1)
  37.                 torchDistance = 0
  38.             else
  39.                 print("Not placing torch. " , torchDistance , "<" , maxTorchDistance)
  40.             end
  41.         else
  42.             print("Warning: No torches!!")
  43.         end
  44. end
  45.  
  46. function digSide()
  47.     for width = 1, maxWidth do
  48.         print("Current Width: ", width)
  49.         while turtle.detect() do
  50.             turtle.dig()
  51.         end
  52.         turtle.forward()
  53.         turtle.digUp()
  54.         turtle.digDown()
  55.     end
  56.     for width = 1, maxWidth do
  57.         turtle.back()
  58.         if placeTorches and not torchAlreadyPlaced then
  59.             placeTorch()
  60.             torchAlreadyPlaced = true
  61.         end
  62.     end
  63.     torchAlreadyPlaced = false
  64. end
  65.  
  66. if turtle.getFuelLevel() < maxDistance*5 then
  67.     print("WARNING: turtle may not have the fuel to move the entire distance required")
  68. end
  69.  
  70. print("Starting mine")
  71.  
  72. while run do
  73.     if turtle.getFuelLevel() <= 0 then
  74.         print("NO FUEL. Stopping.")
  75.         break
  76.     end
  77.     print("Distance: " , currentDistance)
  78.     print("TorchDistance: " , torchDistance)
  79.    
  80.     print("Dig front side")
  81.     while turtle.detect() do
  82.         turtle.dig()
  83.     end
  84.     turtle.digUp()
  85.     turtle.digDown()
  86.    
  87.     if maxWidth > 0 then
  88.         print("Dig right side")
  89.         turtle.turnRight()
  90.         digSide()
  91.         turtle.turnLeft()
  92.     end
  93.    
  94.     if maxWidth > 0 then
  95.         print("Dig left side")
  96.         turtle.turnLeft()
  97.         digSide()
  98.         turtle.turnRight()
  99.     end
  100.    
  101.     if turtle.getItemCount(13) > 0 then
  102.         print("nearly full, chest dumping")
  103.         turtle.select(16)
  104.         turtle.placeDown()
  105.         for a = 1, 14 do
  106.             turtle.select(a)
  107.             turtle.dropDown()
  108.         end
  109.         if turtle.getItemCount(16) < 0 then
  110.             print("Out of chests!! Stopping")
  111.             break
  112.         end
  113.         turtle.select(1)
  114.     end
  115.    
  116.     while turtle.detect() do
  117.         turtle.dig()
  118.     end
  119.         turtle.forward()
  120.    
  121.     currentDistance = currentDistance + 1
  122.     torchDistance = torchDistance + 1
  123.    
  124.     if currentDistance >= maxDistance then
  125.         print("Max distance of " , maxDistance , " reached. Stopping")
  126.         run = false    
  127.     end
  128. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement