Advertisement
Helminthophobe

Hall Mine Left

Jan 24th, 2022 (edited)
894
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. shell.run('clear')
  2. local arg1,arg2 = ...
  3. local length = 0
  4. local torch = false
  5. local torchcount = 0
  6. if (arg1 ~= nill) then
  7.   length = arg1
  8. end
  9. if (arg2 ~= nill) then
  10.   if (arg2 == "y") then
  11.     torch = true
  12.   end
  13. end
  14. local invalid = true
  15.  
  16. function checkFuel()
  17.   if turtle.getFuelLevel() < 100 then
  18.     shell.run("refuel","all")
  19.   end
  20. end
  21.  
  22. function mineTunnel()
  23.   checkFuel()
  24.   if turtle.detect() then
  25.     repeat turtle.dig() until turtle.forward()
  26.   else
  27.     repeat until turtle.forward()
  28.   end
  29.   if turtle.detectDown() then turtle.digDown() end
  30.   if (torch == true) then
  31.     torchcount = torchcount + 1
  32.     if (torchcount == 7) then
  33.       turtle.select(1)
  34.       turtle.placeDown()
  35.       torchcount = 0
  36.     end
  37.   end
  38.   while turtle.detectUp() do
  39.     turtle.digUp()
  40.     sleep(0.5)
  41.   end
  42. end
  43.  
  44. if (length == 0) then
  45.   repeat
  46.     print( "How many blocks to mine?" )
  47.     length = tonumber(io.read())
  48.     if (length == 0) then
  49.       shell.run('clear')
  50.       print( "Entry must be larger than " .. length .. ".")
  51.       invalid = true
  52.     end
  53.     if (length > 0) then
  54.       invalid = false
  55.     end
  56.   until invalid == false
  57. end
  58.  
  59. shell.run('clear')
  60. for i=1,3 do
  61.     mineTunnel()
  62. end
  63. turtle.turnLeft()
  64.  
  65. for i=1,length do
  66.     mineTunnel()
  67. end
  68.  
  69. turtle.turnLeft()
  70. for i=1,2 do
  71.     mineTunnel()
  72. end
  73. turtle.turnLeft()
  74. turtle.turnLeft()
  75. turtle.forward()
  76. turtle.forward()
  77. for i=1,3 do
  78.     mineTunnel()
  79. end
  80. turtle.turnRight()
  81. torchcount = 0
  82.  
  83. for i=1,length do
  84.     mineTunnel()
  85. end
  86. turtle.turnRight()
  87. for i=1,2 do
  88.     mineTunnel()
  89. end
  90. turtle.turnRight()
  91. turtle.turnRight()
  92. turtle.forward()
  93. turtle.forward()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement