Advertisement
aidanbbq

Miner1

Dec 12th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function refuel()
  2.     if turtle.getFuelLevel() < 1 then
  3.         print("Attempting to Refuel!")
  4.         if ~turtle.refuel(10) then
  5.             print("failed to refuel")
  6.         end
  7.     end
  8. end
  9.  
  10. function torch(x)
  11.     if x % 5 == 0 then
  12.         tmp=turtle.getSelectedSlot()
  13.         turtle.turnRight()
  14.         turtle.select(2)
  15.         turtle.dig()
  16.         turtle.place()
  17.         turtle.dig()
  18.         turtle.turnRight()
  19.         turtle.turnRight()
  20.         turtle.forward()
  21.         turtle.turnRight()
  22.         turtle.select(tmp)
  23.     end
  24. end
  25.  
  26. function dig(n)
  27.     for i=0, n-1 do
  28.         refuel()
  29.         if(turtle.detect()) then
  30.             turtle.dig()
  31.         end
  32.         turtle.forward()
  33.         if(turtle.detectUp()) then
  34.             turtle.digUp()
  35.         end
  36.     end
  37. end
  38.  
  39. function cleanup()
  40.     for i=0, 3 do
  41.         dig(1)
  42.         turtle.turnRight()
  43.     end
  44.     turtle.turnLeft()
  45.     dig(3)
  46.     turtle.turnLeft()
  47. end
  48.  
  49. function mineShaft(length)
  50.     for i=0, length do
  51.         dig(1)
  52.         torch(i)
  53.     end
  54.     dig(length)
  55.     turtle.turnRight()
  56.     dig(3)
  57.     turtle.turnRight()
  58.     dig(length)
  59. end
  60.  
  61. function mine(x, y)
  62.     for i=0, y-1 do
  63.         mineShaft(x)
  64.         cleanup()
  65.     end
  66.     turnRight()
  67.     for i=0, (6*y)-1 do
  68.         turtle.forward()
  69.     end
  70. end
  71.  
  72. mine(4, 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement