Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function callError(errorString)
- shell.exit()
- end
- function digUp()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- function moveForward(maxTries)
- for i = 0, maxTries, 1 do
- if turtle.forward() then
- return
- end
- turtle.dig()
- sleep(1)
- end
- callError("Move Forward Error")
- end
- function moveUp(maxTries)
- for i = 0, maxTries, 1 do
- if turtle.up() then
- return
- end
- turtle.digUp()
- sleep(1)
- end
- callError("Move Up Error")
- end
- function makeATurn(turn)
- if turn then
- turtle.turnRight()
- turtle.dig()
- moveForward(10)
- turtle.turnRight()
- else
- turtle.turnLeft()
- turtle.dig()
- moveForward(10)
- turtle.turnLeft()
- end
- end
- function makeATurnUp()
- moveUp(10)
- digUp()
- moveUp(10)
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function mineARow(amount)
- for i = 0, amount - 1, 1 do
- if i < amount - 1 then
- turtle.dig()
- digUp()
- moveForward(10)
- end
- digUp()
- end
- end
- function mineLastRow(amount)
- for i = 0, amount - 1, 1 do
- if i < amount - 1 then
- turtle.dig()
- moveForward(10)
- end
- digUp()
- end
- end
- function mineALayer(amount, length, turn)
- for i = 0, length - 1, 1 do
- mineARow(amount)
- if i < length - 1 then
- makeATurn(turn)
- turn = not turn
- end
- end
- return turn
- end
- function mineLastLayer(amount, length, turn)
- for i = 0, length - 1, 1 do
- mineLastRow(amount)
- if i < length - 1 then
- makeATurn(turn)
- turn = not turn
- end
- end
- end
- function mine(x, y, z)
- turn = true
- turtle.dig()
- moveForward(10)
- for i = 0, y - 1, 2 do
- if i == y - 1 then
- print(turn)
- mineLastLayer(z, x, turn)
- return
- end
- turn = mineALayer(z, x, turn)
- makeATurnUp()
- end
- end
- function startMining()
- print("This turtle is mining from the lower left to the upper right!\n")
- print("X is the width\n")
- print("Y is the height\n")
- print("Z is the depth\n")
- print("X:")
- x = tonumber(read())
- print("Y:")
- y = tonumber(read())
- print("Z:")
- z = tonumber(read())
- print("You entered: X = " .. x .. "Y = " .. y .. "Z = " .. z .. "\n")
- print("Is that correct: Y/N")
- choice = ""
- while true do
- shell.run("clear")
- print(choice .. " is not a valid input! Only use Y or N\n\n")
- print("You entered: X = " .. x .. "Y = " .. y .. "Z = " .. z .. "\n")
- print("Is that correct: Y/N")
- choice = read()
- if choice == "Y" or choice == "N" then
- break
- end
- end
- if choice == "Y" then
- mine(x, y, z)
- end
- end
- startMining()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement