ravneravn

enderMine update

Aug 8th, 2013
32
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. area = 20
  2.  
  3. function moveForward()
  4. while not turtle.forward() do
  5. turtle.dig()
  6. end
  7. end
  8.  
  9. function moveUp()
  10. while not turtle.up() do
  11. turtle.digUp()
  12. currY = currY + 1
  13. end
  14. end
  15.  
  16. --#### COMPARE UP ####
  17. function compareUp()
  18. turtle.select(1)
  19. turtle.compareUp()
  20. if turtle.compareUp() == true then
  21. print("Stone")
  22. else
  23.  
  24. turtle.select(2)
  25. turtle.compareUp()
  26. if turtle.compareUp() == true then
  27. print("Gravel")
  28. else
  29.  
  30. turtle.select(3)
  31. turtle.compareUp()
  32. if turtle.compareUp() == true then
  33. print("Marble")
  34. else
  35.  
  36. turtle.select(4)
  37. turtle.compareUp()
  38. if turtle.compareUp() == true then
  39. print("Dirt")
  40. else
  41.  
  42. turtle.digUp()
  43. print("Valuable found")
  44. end
  45. end
  46. end
  47. end
  48. end
  49.  
  50. --#### COMPARE DOWN ####
  51. function compareDown()
  52. turtle.select(1)
  53. turtle.compareDown()
  54. if turtle.compareDown() == true then
  55. print("Stone")
  56. else
  57.  
  58. turtle.select(2)
  59. turtle.compareDown()
  60. if turtle.compareDown() == true then
  61. print("Gravel")
  62. else
  63.  
  64. turtle.select(3)
  65. turtle.compareDown()
  66. if turtle.compareDown() == true then
  67. print("Marble")
  68. else
  69.  
  70. turtle.select(4)
  71. turtle.compareDown()
  72. if turtle.compareDown() == true then
  73. print("Dirt")
  74. else
  75.  
  76. turtle.digDown()
  77. print("Valuable found")
  78. end
  79. end
  80. end
  81. end
  82. end
  83.  
  84. --#### DROP OFF ####
  85. function dropOff()
  86. turtle.dig()
  87. turtle.select(16)
  88. turtle.place()
  89. for i = 5, 15 do
  90. turtle.select(i)
  91. turtle.drop()
  92. end
  93. turtle.select(16)
  94. turtle.dig()
  95. end
  96.  
  97. --#### MINE ROW ####
  98. function mineRow()
  99. for i = 1, area do
  100. moveForward()
  101. compareUp()
  102. compareDown()
  103. end
  104. dropOff()
  105. end
  106.  
  107. --#### MINE 10x10 ###
  108. function mineSquare()
  109. for i = 1, area/2 do
  110. mineRow()
  111. turtle.turnRight()
  112. moveForward()
  113. turtle.turnRight()
  114. mineRow()
  115. turtle.turnLeft()
  116. moveForward()
  117. turtle.turnLeft()
  118. end
  119.  
  120. turtle.turnLeft()
  121. for i = 1, area do
  122. moveForward()
  123. end
  124.  
  125. turtle.turnRight()
  126. for i = 1,3 do
  127. moveUp()
  128. currY = currY + 1
  129. writeYLevel()
  130. end
  131.  
  132. end
  133.  
  134. -- #### MINE SEVERAL ROWS ####
  135. function mine()
  136. layers = math.floor(yStart / 4)
  137. for i = 1, layers do
  138. mineSquare()
  139. end
  140. end
  141.  
  142.  
  143.  
  144. --#### TO BEDROCK ####
  145. function toBedrock()
  146. mineStart = yStart - 6
  147. currY = yStart
  148. for i = 1, mineStart do
  149. turtle.digDown()
  150. turtle.down()
  151. currY = currY - 1
  152. end
  153. writeYLevel()
  154. end
  155.  
  156.  
  157. -- #### RETURN TO SURFACE ####
  158. function goUp()
  159. for i = 1, yStart - currY do
  160. moveUp()
  161. currY = currY +1
  162. writeYLevel()
  163. end
  164. end
  165.  
  166. -- ## WRITE FILE ##
  167. function writeStartLevel()
  168. handle = fs.open("startLevel", "w")
  169. handle.write(yStart)
  170. handle.close()
  171. end
  172.  
  173. function writeYLevel()
  174. handle = fs.open("yLevel", "w")
  175. handle.write(currY)
  176. handle.close()
  177. end
  178.  
  179.  
  180.  
  181.  
  182.  
  183. --#### LOOP ####
  184. print("What is my Y level?")
  185. yStart = io.read()
  186. writeStartLevel()
  187.  
  188. print("I will mine a "..area.."x"..area.." area")
  189.  
  190. toBedrock()
  191. mine()
  192. goUp()
  193.  
  194. print("finished")
RAW Paste Data