Advertisement
Guest User

Untitled

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