Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function takeinput()
- print("What is the current y value of the turtle?")
- y = tonumber(read())
- print("How long is the intended quarry lengthwise? (In front of and including the turtle.)")
- l = tonumber(read())
- print("And how long the width of this quarry?(To the right of and including the turtle.)")
- w = tonumber(read())
- if type(y) == "nil" or type(l) == "nil" or type(w) == "nil" then
- print("\nAll inputs must be numerical, try again.\n")
- takeinput()
- elseif y <= 4 then
- print("\nYour y value must be above bedrock. Please either move the turtle above the bedrock layers or enter the correct value.\n")
- takeinput()
- else
- return y, l, w
- end
- print("Finished takeinput")
- end
- function isOre(s)
- print("Running isOre")
- if string.find(s,"ore") then
- return true
- end
- print("Finished isOre")
- end
- function selectEmpty()
- print("Running selectEmpty")
- for i=1, 16 do
- if turtle.getItemCount(i) == 0 then
- turtle.select(i)
- return true
- end
- end
- print("Finished selectEmpty")
- end
- function mine(y, l, w)
- for i=y, 6, -1 do
- useless, block = turtle.inspectDown()
- if not turtle.detectDown() then
- turtle.down()
- elseif isOre(block.name) then
- turtle.select(1)
- turtle.digDown()
- turtle.down()
- else
- selectEmpty()
- turtle.digDown()
- turtle.dropUp()
- turtle.down()
- end
- end
- for i=1, 11 do
- if turtle.detect() then
- useless, block = turtle.inspect()
- end
- for i=1, w do
- if turtle.detectUp() then
- useless, block = turtle.inspectUp()
- end
- for j=1, l-1 do
- if turtle.detect() then
- useless, block = turtle.inspect()
- end
- if not turtle.detect() then
- turtle.forward()
- elseif isOre(block.name) then
- turtle.select(1)
- turtle.dig()
- turtle.forward()
- else
- selectEmpty()
- turtle.dig()
- turtle.drop()
- turtle.forward()
- end
- end
- if not (i == w) then
- if (i % 2) == 0 then
- turtle.turnLeft()
- if not turtle.detect() then
- turtle.forward()
- turtle.turnLeft()
- elseif isOre(block.name) then
- turtle.select(1)
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- else
- selectEmpty()
- turtle.dig()
- turtle.drop()
- turtle.forward()
- turtle.turnLeft()
- end
- else
- turtle.turnRight()
- if not turtle.detect() then
- turtle.forward()
- turtle.turnRight()
- elseif isOre(block.name) then
- turtle.select(1)
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- else
- selectEmpty()
- turtle.dig()
- turtle.drop()
- turtle.forward()
- turtle.turnRight()
- end
- end
- end
- end
- if not turtle.detectUp() then
- turtle.up()
- turtle.turnRight()
- elseif isOre(block.name) then
- turtle.select(1)
- turtle.digUp()
- turtle.up()
- turtle.turnRight()
- else
- selectEmpty()
- turtle.digUp()
- turtle.dropDown()
- turtle.up()
- turtle.turnRight()
- end
- end
- end
- mine(takeinput())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement