mjmac85

Untitled

Mar 21st, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.73 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3.  
  4. repeat
  5. print("Enter tunnel Length (even number): ")
  6. length = read()
  7. print("Enter height (even number): ")
  8. height = read()
  9. print("Enter Width (even number): ")
  10. width = read()
  11. until length % 2 == 0
  12. term.clear()
  13. repeat
  14. print("Place fuel in slot 1.")
  15. until turtle.getItemCount(1) >= 0
  16. repeat
  17. print("Place torches in slot 2.")
  18. until turtle.getItemCount(2) ~= 0
  19.  
  20. print("Place chest behind turtle.\n")
  21.  
  22. term.clear()
  23. print("Here we go!")
  24. torchpos = 0
  25.  
  26.  
  27. function fuel()
  28.     if turtle.getFuelLevel() < 0.26 then
  29.         turtle.select(1)
  30.         turtle.refuel(1)
  31.     end
  32. end
  33.  
  34. function mine()
  35.     local LoopHeight = 0
  36.     local LoopWidth = 0
  37.     local LoopLength = 0
  38.  
  39.     fuel()
  40. --odd numbers left even numbers right
  41.     for LoopLength = 0, length -1 do
  42.         for LoopHeight = 0, height - 1 do
  43.             if LoopHeight % 2 == 0 then
  44.                 turtle.turnLeft()
  45.                 for LoopWidth = 0, width -1 do
  46.                     leftUp()
  47.                 end
  48.                 turtle.turnRight()
  49.             else
  50.                 turtle.turnRight()
  51.                 for LoopWidth = 0, width -1 do
  52.                     rightUp()
  53.                 end
  54.                 turtle.turnLeft()
  55.             end
  56.             if LoopWidth == width -1 then
  57.                 if LoopWidth % 2 == 0 then
  58.                     turtle.turnRight()
  59.                 else
  60.                     turtle.turnLeft()
  61.                 end
  62. print("move forward")
  63.                 checkEmptySpace()
  64.                 turtle.forward()
  65.             else
  66. print("Down")
  67.                 if turtle.detectDown() == true then
  68.                     turtle.digDown()
  69.                 end
  70.                 turtle.down()
  71.             end
  72.         end
  73.     if LoopLength % 2 == 0 then
  74.         turtle.turnRight()
  75.     else
  76.         turtle.turnLeft()
  77.     end
  78.        
  79.     end
  80. end
  81.  
  82.                
  83. function checkEmptySpace()
  84.     while turtle.detect() == true do
  85.         turtle.dig()
  86.     end
  87. end        
  88.                
  89. function leftUp()
  90.  
  91.     checkEmptySpace()
  92.     turtle.forward()
  93.    
  94. end
  95.  
  96. function rightUp()
  97.     checkEmptySpace()
  98.     turtle.forward()
  99. end
  100.  
  101. mine()
Advertisement
Add Comment
Please, Sign In to add comment