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 putWhere(sample)
- print("Running putWhere")
- for i=1, 16 do
- if turtle.getItemDetail(i).name == sample then
- turtle.select(i)
- return true
- end
- end
- print("Finished putWhere")
- end
- function mine(y, l, w)
- for i=y, 6, -1 do
- local useless, block = turtle.inspectDown()
- if not turtle.detectDown() then
- turtle.down()
- elseif isOre(block.name) then
- putWhere(block.name)
- turtle.digDown()
- turtle.down()
- selectEmpty()
- else
- turtle.digDown()
- turtle.dropUp()
- turtle.down()
- end
- end
- for i=1, w do
- if not turtle.detect() then
- local useless, block = turtle.inspect()
- end
- for i=1, l-1 do
- if not turtle.detect() then
- local useless, block = turtle.inspect()
- end
- if not turtle.detect() then
- turtle.forward()
- elseif isOre(block.name) then
- putWhere(block.name)
- turtle.dig()
- turtle.forward()
- selectEmpty()
- else
- turtle.dig()
- turtle.drop()
- turtle.forward()
- end
- turtle.turnRight()
- if not turtle.detect() then
- turtle.forward()
- turtle.turnRight()
- elseif isOre(block.name) then
- putWhere(block.name)
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- selectEmpty()
- else
- turtle.dig()
- turtle.drop()
- turtle.forward()
- turtle.turnRight()
- end
- end
- end
- return true
- end
- mine(takeinput())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement