Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mineHeight = 0;
- local run = true;
- local currentRotation = 0
- local currentYPosition = 0
- local currentZPosition = 0
- local oldYPosition = 0
- local oldZPosition = 0
- local oldRotation = 0
- function turnLeft()
- currentRotation = currentRotation - 1;
- turtle.turnLeft()
- end
- function turnRight()
- currentRotation = currentRotation + 1;
- turtle.turnRight()
- end
- function dig()
- print("Digging! " .. " Y: " .. currentYPosition .. " Z: " .. currentZPosition .. " Rotation: " .. currentRotation)
- if turtle.getItemCount(16) == 0 then
- turtle.dig()
- else
- returnToHome()
- deposit()
- returnToOldPosition()
- end
- end
- function digUp()
- if turtle.getItemCount(16) == 0 then
- turtle.digUp()
- else
- returnToHome()
- deposit()
- returnToOldPosition()
- end
- end
- function digDown()
- if turtle.getItemCount(16) == 0 then
- turtle.digDown()
- else
- returnToHome()
- deposit()
- returnToOldPosition()
- end
- end
- function oddLevelDig()
- dig()
- turnRight()
- dig()
- turnRight()
- dig()
- end
- function evenLevelDig()
- dig()
- turnLeft()
- dig()
- turnLeft()
- dig()
- end
- function turnStraight()
- print("Turning straight")
- if currentRotation > 0 then
- repeat
- turnLeft()
- until currentRotation == 0
- else
- repeat
- turnRight()
- until currentRotation == 0
- end
- end
- function turnBackwards()
- print("Turning backwards")
- if currentRotation > 0 then
- repeat
- turnRight()
- until currentRotation == 2
- else
- repeat
- turnLeft()
- until currentRotation == -2
- end
- end
- function returnToHome()
- turnBackwards()
- for i = 1, currentZPosition do
- turtle.forward()
- end
- for i = 1, currentYPosition do
- turtle.down()
- end
- end
- function deposit()
- for i = 1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- end
- function returnToOldPosition()
- turnStraight()
- for i = 1, currentZPosition do
- turtle.forward()
- end
- for i = 1, currentYPosition do
- turtle.up()
- end
- end
- write("Mine Height: ")
- mineHeight = tonumber(read());
- turtle.select(1)
- turtle.refuel()
- while run do
- turnLeft()
- for i = 1, mineHeight do
- print("Starting to mine at height: " .. i)
- if i % 2 == 1 then
- oddLevelDig()
- else
- evenLevelDig()
- end
- if i ~= mineHeight then
- digUp()
- turtle.up()
- currentYPosition = currentYPosition + 1
- end
- end
- turnStraight()
- turtle.forward()
- currentZPosition = currentZPosition + 1
- turnLeft()
- for i = mineHeight, 1, -1 do
- print("Starting to mine at height: " .. i)
- if i % 2 == 1 then
- oddLevelDig()
- else
- evenLevelDig()
- end
- if i ~= 1 then
- digDown()
- turtle.down()
- currentYPosition = currentYPosition - 1
- end
- end
- turnStraight()
- turtle.forward()
- currentZPosition = currentZPosition + 1
- end
- --loadstring(http.get("https://pastebin.com/raw/f6CQKKwP").readAll())()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement