Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 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 putWhere(sample)
  43. print("Running putWhere")
  44. for i=1, 16 do
  45. if turtle.getItemDetail(i).name == sample then
  46. turtle.select(i)
  47. return true
  48. end
  49. end
  50. print("Finished putWhere")
  51. end
  52.  
  53.  
  54. function mine(y, l, w)
  55. for i=y, 6, -1 do
  56. local useless, block = turtle.inspectDown()
  57. if not turtle.detectDown() then
  58. turtle.down()
  59. elseif isOre(block.name) then
  60. putWhere(block.name)
  61. turtle.digDown()
  62. turtle.down()
  63. selectEmpty()
  64. else
  65. turtle.digDown()
  66. turtle.dropUp()
  67. turtle.down()
  68. end
  69. end
  70.  
  71. for i=1, w do
  72. if not turtle.detect() then
  73. local useless, block = turtle.inspect()
  74. end
  75. for i=1, l-1 do
  76. if not turtle.detect() then
  77. local useless, block = turtle.inspect()
  78. end
  79. if not turtle.detect() then
  80. turtle.forward()
  81. elseif isOre(block.name) then
  82. putWhere(block.name)
  83. turtle.dig()
  84. turtle.forward()
  85. selectEmpty()
  86. else
  87. turtle.dig()
  88. turtle.drop()
  89. turtle.forward()
  90. end
  91.  
  92. turtle.turnRight()
  93. if not turtle.detect() then
  94. turtle.forward()
  95. turtle.turnRight()
  96. elseif isOre(block.name) then
  97. putWhere(block.name)
  98. turtle.dig()
  99. turtle.forward()
  100. turtle.turnRight()
  101. selectEmpty()
  102. else
  103. turtle.dig()
  104. turtle.drop()
  105. turtle.forward()
  106. turtle.turnRight()
  107. end
  108. end
  109. end
  110. return true
  111. end
  112.  
  113.  
  114. mine(takeinput())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement