Advertisement
Guest User

mine3

a guest
Jul 1st, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.63 KB | None | 0 0
  1. if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 then
  2.   turtle.refuel()
  3. end
  4.  
  5. print("Enter the width, height, and depth in that order.")
  6.  
  7. local width = tonumber(read())
  8. local height = tonumber(read())
  9. local depth = tonumber(read())
  10.  
  11. function mineforward ()
  12.   for i=2, width, 1 do
  13.     while turtle.detect() do
  14.         turtle.dig()
  15.       os.sleep(0.5)
  16.     end
  17.     turtle.forward()
  18.   end
  19. end
  20.  
  21. function invcheck ()
  22.   if turtle.getItemCount(16) > 1 then
  23.     return true
  24.   else
  25.     return false
  26.   end
  27. end
  28.  
  29. function finishmine()
  30.   if height % 2 == 0 then
  31.     turtle.turnRight()
  32.     for i=1, height, 1 do
  33.       turtle.down()
  34.     end
  35.   else
  36.     turtle.turnLeft()
  37.     turtle.turnLeft()
  38.     mineforward()
  39.     turtle.turnRight()
  40.   end
  41. end
  42.  
  43. local count = 0
  44.  
  45.   if turtle.detect() then
  46.  
  47.     for i=1, depth, 1 do
  48.       while turtle.detect() do
  49.         turtle.dig()
  50.         os.sleep(0.5)
  51.       end
  52.  
  53.       os.sleep(0.5)
  54.       turtle.forward()
  55.       turtle.turnRight()
  56.    
  57.       for i=1, height, 1 do
  58.       mineforward()
  59.       if i == height then
  60.         finishmine()
  61.       else
  62.         turtle.digUp()
  63.         turtle.up()
  64.         turtle.turnLeft()
  65.         turtle.turnLeft()
  66.       end
  67.     end
  68.     count = count + 1
  69.       if invcheck() then
  70.          for i=1, count, 1 do
  71.             turtle.back()
  72.         end
  73.        
  74.         turtle.up()
  75.         turtle.back()
  76.        
  77.         for i=1, 16, 1 do
  78.       turtle.select(i)
  79.       turtle.dropDown()
  80.         end
  81.        
  82.   turtle.select(1)
  83.         turtle.forward()
  84.         turtle.down()
  85.        
  86.         for i=1, count, 1 do
  87.           turtle.forward()
  88.         end
  89.       end
  90.     end
  91.   else
  92.     print("Place me in front of a block!")
  93.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement