Advertisement
clumsyfunk

TurtleMine2020

Feb 19th, 2020
597
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local digDepth = 32
  2. local digWidth = 7
  3. local torchSpacing = 4
  4. local currentDepth = torchSpacing - 1
  5. local digHeight = 12
  6. local chestSlot = 14
  7. local torchSlot = 15
  8. local fuelSlot = 16
  9.  
  10.  
  11. function checkFuel()
  12.     if turtle.getFuelLevel() < 120 then
  13.         turtle.select(fuelSlot)
  14.         turtle.refuel(2)
  15.         turtle.select(1)
  16.     end
  17. end
  18.  
  19. function checkInv()
  20.   if turtle.getItemCount(11) > 0 then
  21.     goAround()
  22.     turtle.select(chestSlot)
  23.     while turtle.place() == false do
  24.       turtle.dig()
  25.       turtle.attack()
  26.     end
  27.     for i = 1, 13 do
  28.       turtle.select(i)
  29.       turtle.drop()
  30.     end
  31.     goAround()
  32.     turtle.select(1)
  33.   end
  34. end
  35.  
  36. function placeTorch()
  37.     turtle.select(torchSlot)
  38.   goAround()
  39.     turtle.place()
  40.   goAround()
  41.     turtle.select(1)
  42. end
  43.  
  44. function goForward(times)
  45.   for i = 1, times do
  46.     while turtle.forward() == false do
  47.       turtle.attack()
  48.       turtle.dig()
  49.     end
  50.  
  51.     if i == 4 and currentDepth == torchSpacing then
  52.       placeTorch()
  53.       currentDepth = 0
  54.     end
  55.  
  56.   end
  57. end
  58.  
  59. function goAround()
  60.   for i = 1, 2 do
  61.     turtle.turnLeft()
  62.   end
  63. end
  64.  
  65. function goUp()
  66.   while turtle.up() == false do
  67.     turtle.attackUp()
  68.     turtle.digUp()
  69.   end
  70. end
  71.  
  72. function goDown(times)
  73.   for i = 1, times do
  74.     while turtle.down() == false do
  75.       turtle.attackDown()
  76.       turtle.digDown()
  77.     end
  78.   end
  79. end
  80.  
  81. function digMine()
  82.  
  83.   local currentHeight = 1
  84.   goForward(1)
  85.   currentDepth = currentDepth + 1
  86.   turtle.turnLeft()
  87.  
  88.   for i = 1, digHeight do
  89.     goForward(digWidth -1)
  90.     goAround()
  91.     if currentHeight ~= digHeight then
  92.       goUp()
  93.       currentHeight = currentHeight + 1
  94.     end
  95.   end
  96.  
  97.   goDown(currentHeight -1)
  98.   turtle.turnRight()
  99.  
  100. end
  101.  
  102.  
  103.  
  104. function turtleStart()
  105.     for i = 1, digDepth do
  106.         checkFuel()
  107.     checkInv()
  108.     digMine()
  109.     end
  110. end
  111.  
  112. turtleStart()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement