mjmac85

Untitled

Mar 21st, 2013
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. if LoopLength > 1 then
  48. print("LoopLength: ", LoopLength)
  49. print("LoopHeight: ", LoopHeight)
  50. print("Width: ", width)
  51. read()
  52. end
  53.  
  54. for LoopWidth = 0, width -2 do
  55. leftDown()
  56. --print("LoopWidthL: ", LoopWidth)
  57. end
  58. if LoopHeight == height - 1 then
  59. endHeightCheck(LoopWidth, LoopLength)
  60. end
  61. turtle.turnRight()
  62. else
  63. turtle.turnRight()
  64. for LoopWidth = 0, width -2 do
  65. rightDown()
  66. --print("LoopWidthR: ", LoopWidth)
  67. end
  68. if LoopHeight == height - 1 then
  69. endHeightCheck(LoopWidth, LoopLength)
  70. end
  71. turtle.turnLeft()
  72. end
  73. if LoopHeight ~= height - 1 then
  74. if LoopLength % 2 == 0 then
  75. checkEmptyDown()
  76. else
  77. checkEmptyUp()
  78. end
  79. end
  80. end
  81. if LoopLength % 2 == 0 then
  82. turtle.turnRight()
  83. print("Length check Right: ")
  84. read()
  85. else
  86. turtle.turnLeft()
  87. print("Length check left: ")
  88. read()
  89. end
  90.  
  91. end
  92. end
  93.  
  94.  
  95. function checkEmptySpace()
  96. while turtle.detect() == true do
  97. turtle.dig()
  98. end
  99. end
  100.  
  101. function leftDown()
  102. checkEmptySpace()
  103. turtle.forward()
  104. end
  105.  
  106. function rightDown()
  107. checkEmptySpace()
  108. turtle.forward()
  109. end
  110. function checkEmptyDown()
  111. if turtle.detectDown() == true then
  112. turtle.digDown()
  113. end
  114. turtle.down()
  115. end
  116.  
  117. function checkEmptyUp()
  118. if turtle.detectUp() == true then
  119. turtle.digUp()
  120. end
  121. turtle.up()
  122. end
  123.  
  124. function endHeightCheck(LoopWidth, LoopLength)
  125. if LoopLength % 2 == 0 then
  126. if LoopWidth % 2 == 1 then
  127. turtle.turnRight()
  128. checkEmptySpace()
  129. turtle.forward()
  130. else
  131. turtle.turnLeft()
  132. checkEmptySpace()
  133. turtle.forward()
  134. end
  135. else
  136. if LoopWidth % 2 == 0 then
  137. turtle.turnRight()
  138. checkEmptySpace()
  139. turtle.forward()
  140. else
  141. turtle.turnLeft()
  142. checkEmptySpace()
  143. turtle.forward()
  144. end
  145. end
  146. end
  147. mine()
Advertisement
Add Comment
Please, Sign In to add comment