Advertisement
Laurelianae

Mining Turtle

Jun 18th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.00 KB | None | 0 0
  1. local args = {...}
  2.  
  3. local stripLength = 32
  4.  
  5. if not #args == 1 then
  6.   print("Usage: smine <mines>")
  7.   return
  8. end
  9.  
  10. function strip()
  11.   for i=1,stripLength do
  12.     checkFuel()
  13.     checkInv()
  14.     while not turtle.forward() do turtle.dig() end
  15.     while turtle.detectUp() do
  16.       turtle.digUp()
  17.       sleep(0.2)
  18.     end
  19.     while turtle.detectDown() do
  20.       turtle.digDown()
  21.       sleep(0.2)
  22.     end
  23.    
  24.     if i%8 == 0 then
  25.       turtle.select(16)
  26.       while not turtle.forward() do turtle.dig() end
  27.       while turtle.detectUp() do
  28.         turtle.digUp()
  29.         sleep(0.2)
  30.       end
  31.       if not turtle.back() then
  32.         turtle.turnLeft()
  33.         turtle.turnLeft()
  34.         while not turtle.forward do turtle.dig() end
  35.         turtle.turnLeft()
  36.         turtle.turnLeft()
  37.       end
  38.       turtle.placeUp()
  39.       turtle.select(1)
  40.     end
  41.   end
  42.  
  43.   turtle.turnLeft()
  44.   turtle.turnLeft()
  45.  
  46.   for i=1,stripLength do
  47.     while not turtle.forward() do turtle.dig() end
  48.   end
  49. end
  50.  
  51. function checkFuel()
  52.   if turtle.getFuelLevel() <= 64 then
  53.     print("Error: Low fuel")
  54.     for i=1,14 do
  55.       turtle.select(i)
  56.       turtle.refuel()
  57.     end
  58.   end
  59. end
  60.  
  61. function advance()
  62.     print("Moving to next stripmine")
  63.     for y=1,3 do
  64.         turtle.dig() -- Digs first Block in front
  65.         turtle.forward()
  66.         turtle.digUp()
  67.         turtle.up()
  68.         turtle.digUp()
  69.         turtle.down()
  70.     end
  71. end
  72.  
  73. function checkInv()
  74.   isFull = true
  75.  
  76.   for i=1,14 do
  77.     if turtle.getItemCount(i) == 0 then
  78.       isFull = false
  79.     end
  80.   end
  81.  
  82.   if isFull == true then
  83.     turtle.select(15)
  84.     while not turtle.placeDown() do turtle.digDown() end
  85.     for i=1,14 do
  86.       turtle.select(i)
  87.       turtle.dropDown()
  88.     end
  89.   end
  90. end
  91.  
  92. print("Place torches in slot 16")
  93. print("Place chest/s in slot 15 (will be automatically placed and filled when inventory is full)")
  94.  
  95. for x=1,args[1] do
  96.   turtle.turnLeft()
  97.   strip()
  98.   strip()
  99.   turtle.turnRight()
  100.   advance()
  101. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement