McKillopBK

StripMine

Oct 18th, 2021
856
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local times = 0
  2. local j = 0
  3.  
  4. function Mine()
  5.   while turtle.detect() == true do
  6.     turtle.dig()
  7.     sleep(0.50)
  8.   end
  9.   turtle.forward()
  10.   sleep(0.50)
  11.   while turtle.detectUp() == true do
  12.     turtle.digUp()
  13.     sleep(0.50)
  14.   end
  15.   turtle.digDown()
  16. end
  17.  
  18. function Place(SlotNum)
  19.   turtle.select(SlotNum)
  20.   turtle.back()
  21.   turtle.placeUp()
  22.   turtle.forward()
  23. end
  24.  
  25. function PlaceChest(SlotNum)
  26.   turtle.select(SlotNum)
  27.   turtle.back()
  28.   turtle.placeDown()
  29.   for I=1, 14 do
  30.     turtle.select(I)
  31.     turtle.dropDown()
  32.   end
  33.   turtle.forward()
  34. end
  35.  
  36. print("Place chests in slot 15.")
  37. print("Place torches in slot 16.")
  38. term.write("How long is the mineshaft? ")
  39. times = read()
  40.  
  41. function Digger()
  42.   for i=1, times do
  43.     j = j+1
  44.     Mine()
  45.     if j == 9 then
  46.           Place(16)
  47.           j = 0
  48.     end
  49.   end
  50. end
  51.  
  52. function TunnelLeft()
  53.   turtle.turnRight()
  54.   Mine()
  55.   Mine()
  56.   Place(16)
  57.   PlaceChest(15)
  58.   Mine()
  59.   turtle.turnRight()
  60. end
  61.  
  62. function TunnelRight()
  63.   turtle.turnLeft()
  64.   Mine()
  65.   Mine()
  66.   Place(16)
  67.   PlaceChest(15)
  68.   Mine()
  69.   turtle.turnLeft()
  70. end
  71.  
  72. function EndLeft()
  73.   turtle.turnLeft()
  74.   Mine()
  75.   Mine()
  76.   Place(16)
  77.   Mine()
  78.   turtle.turnLeft()
  79. end
  80.  
  81. function EndRight()
  82.   turtle.turnRight()
  83.   Mine()
  84.   Mine()
  85.   Place(16)
  86.   Mine()
  87.   turtle.turnRight()
  88. end
  89.  
  90. function CheckFuel()
  91.   if turtle.getFuelLevel() <= 1000 then
  92.     term.write("Low Fuel, Please refuel. Hit any key to continue.")
  93.     os.pullEvent("char")
  94.   end
  95. end
  96.  
  97. term.write("How many double shafts? ")
  98. duration = read()
  99.  
  100. term.write("Which direction are you mining? ")
  101. direction = read()
  102.  
  103. while( not (direction == "left" or direction == "right") ) do
  104.         term.write("Invalid Answer! Try again (left/right): ")
  105.         direction = read()
  106.     end
  107.     if direction == "left" then
  108.         print("Mining Left")
  109.         for i=1, duration do
  110.           CheckFuel()
  111.           Digger()
  112.           EndLeft()
  113.           Digger()
  114.           TunnelLeft()
  115.         end
  116.     else
  117.         print("Mining Right")
  118.         for i=1, duration do
  119.           CheckFuel()
  120.           Digger()
  121.           EndRight()
  122.           Digger()
  123.           TunnelRight()
  124.         end
  125.     end
RAW Paste Data