Advertisement
Guest User

mine

a guest
Feb 21st, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.62 KB | None | 0 0
  1. function takeinput()
  2. print("What is the current y value of the turtle?")
  3. y = tonumber(read())
  4. print("How long is the intended quarry lengthwise? (In front of and including the turtle.)")
  5. l = tonumber(read())
  6. print("And how long the width of this quarry?(To the right of and including the turtle.)")
  7. w = tonumber(read())
  8. if type(y) == "nil" or type(l) == "nil" or type(w) == "nil" then
  9. print("\nAll inputs must be numerical, try again.\n")
  10. takeinput()
  11. elseif y <= 4 then
  12. print("\nYour y value must be above bedrock. Please either move the turtle above the bedrock layers or enter the correct value.\n")
  13. takeinput()
  14. else
  15. return y, l, w
  16. end
  17. print("Finished takeinput")
  18. end
  19.  
  20.  
  21. function isOre(s)
  22. print("Running isOre")
  23. if string.find(s,"ore") then
  24. return true
  25. end
  26. print("Finished isOre")
  27. end
  28.  
  29.  
  30. function selectEmpty()
  31. print("Running selectEmpty")
  32. for i=1, 16 do
  33. if turtle.getItemCount(i) == 0 then
  34. turtle.select(i)
  35. return true
  36. end
  37. end
  38. print("Finished selectEmpty")
  39. end
  40.  
  41.  
  42. function mine(y, l, w)
  43. for i=y, 6, -1 do
  44. useless, block = turtle.inspectDown()
  45. if not turtle.detectDown() then
  46. turtle.down()
  47. elseif isOre(block.name) then
  48. turtle.select(1)
  49. turtle.digDown()
  50. turtle.down()
  51. else
  52. selectEmpty()
  53. turtle.digDown()
  54. turtle.dropUp()
  55. turtle.down()
  56. end
  57. end
  58.  
  59.  
  60. for i=1, 11 do
  61.  
  62. if turtle.detect() then
  63. useless, block = turtle.inspect()
  64. end
  65.  
  66. for i=1, w do
  67.  
  68. if turtle.detectUp() then
  69. useless, block = turtle.inspectUp()
  70. end
  71.  
  72. for j=1, l-1 do
  73.  
  74. if turtle.detect() then
  75. useless, block = turtle.inspect()
  76. end
  77.  
  78. if not turtle.detect() then
  79. turtle.forward()
  80. elseif isOre(block.name) then
  81. turtle.select(1)
  82. turtle.dig()
  83. turtle.forward()
  84. else
  85. selectEmpty()
  86. turtle.dig()
  87. turtle.drop()
  88. turtle.forward()
  89. end
  90. end
  91.  
  92. if not (i == w) then
  93. if (i % 2) == 0 then
  94. turtle.turnLeft()
  95. if not turtle.detect() then
  96. turtle.forward()
  97. turtle.turnLeft()
  98. elseif isOre(block.name) then
  99. turtle.select(1)
  100. turtle.dig()
  101. turtle.forward()
  102. turtle.turnLeft()
  103. else
  104. selectEmpty()
  105. turtle.dig()
  106. turtle.drop()
  107. turtle.forward()
  108. turtle.turnLeft()
  109. end
  110. else
  111. turtle.turnRight()
  112. if not turtle.detect() then
  113. turtle.forward()
  114. turtle.turnRight()
  115. elseif isOre(block.name) then
  116. turtle.select(1)
  117. turtle.dig()
  118. turtle.forward()
  119. turtle.turnRight()
  120. else
  121. selectEmpty()
  122. turtle.dig()
  123. turtle.drop()
  124. turtle.forward()
  125. turtle.turnRight()
  126. end
  127. end
  128. end
  129. end
  130. if not turtle.detectUp() then
  131. turtle.up()
  132. turtle.turnRight()
  133. elseif isOre(block.name) then
  134. turtle.select(1)
  135. turtle.digUp()
  136. turtle.up()
  137. turtle.turnRight()
  138. else
  139. selectEmpty()
  140. turtle.digUp()
  141. turtle.dropDown()
  142. turtle.up()
  143. turtle.turnRight()
  144. end
  145.  
  146.  
  147. end
  148. end
  149.  
  150. mine(takeinput())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement