mjmac85

Untitled

Mar 21st, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 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. while turtle.getItemCount(1) == 0 do
  14. print("Place fuel in slot 1.")
  15. read()
  16. end
  17. while turtle.getItemCount(2) == 0 do
  18. print("Place torches in slot 2.")
  19. read()
  20. end
  21.  
  22. print("Place chest behind turtle.\n")
  23.  
  24. term.clear()
  25. print("Here we go!")
  26. torchpos = 0
  27.  
  28.  
  29. function fuel()
  30. if turtle.getFuelLevel() < 0.26 then
  31. turtle.select(1)
  32. turtle.refuel(1)
  33. end
  34. end
  35.  
  36. function mine()
  37. local LoopHeight = 0
  38. local LoopWidth = 0
  39. local LoopLength = 0
  40.  
  41. fuel()
  42. --odd numbers left even numbers right
  43. for LoopLength = 0, length - 1 do
  44. for LoopHeight = 0, height - 1 do
  45. if LoopHeight % 2 == 0 then
  46. turtle.turnLeft()
  47. for LoopWidth = 0, width -1 do
  48. leftDown()
  49. print("LoopWidthL: ", LoopWidth)
  50. end
  51. if LoopHeight == height - 1 then
  52. endHeightCheck(LoopWidth)
  53. end
  54. turtle.turnRight()
  55. else
  56. turtle.turnRight()
  57. for LoopWidth = 0, width -1 do
  58. rightDown()
  59. print("LoopWidthR: ", LoopWidth)
  60. end
  61. if LoopHeight == height - 1 then
  62. endHeightCheck(LoopWidth)
  63. end
  64.  
  65. turtle.turnLeft()
  66. end
  67. if LoopHeight ~= height - 1 then
  68. checkEmptyDown()
  69. end
  70. end
  71. if LoopLength % 2 == 0 then
  72. turtle.turnRight()
  73. else
  74. turtle.turnLeft()
  75. end
  76.  
  77. end
  78. end
  79.  
  80.  
  81. function checkEmptySpace()
  82. while turtle.detect() == true do
  83. turtle.dig()
  84. end
  85. end
  86.  
  87. function leftDown()
  88. checkEmptySpace()
  89. turtle.forward()
  90. end
  91.  
  92. function rightDown()
  93. checkEmptySpace()
  94. turtle.forward()
  95. end
  96. function checkEmptyDown()
  97. if turtle.detectDown() == true then
  98. turtle.digDown()
  99. end
  100. turtle.down()
  101. end
  102.  
  103. function endHeightCheck(LoopWidth)
  104. if LoopWidth % 2 == 1 then
  105. print("R")
  106. turtle.turnRight()
  107. checkEmptySpace()
  108. turtle.forward()
  109. print("0: ")
  110. read()
  111. else
  112. print("L")
  113. turtle.turnLeft()
  114. checkEmptySpace()
  115. turtle.forward()
  116. print("1: ")
  117. read()
  118. end
  119. end
  120. mine()
Advertisement
Add Comment
Please, Sign In to add comment