Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Current x coordinate:")
- Coordx = read()
- print("Current y coordinate:")
- Coordy = read()
- print("Current z coordinate:")
- Coordz = read()
- print("Currently Faceing(0,1,2,3):")
- rotation = read()
- startX = Coordx
- startY = Coordy
- startZ = Coordz
- function turnLeft()
- turtle.turnLeft()
- rotation = rotation - 1
- if rotation == -1 then
- rotation = 3
- end
- end
- function turnRight()
- turtle.turnRight()
- rotation = rotation + 1
- if rotation == 4 then
- rotation = 0
- end
- end
- function dig()
- repeat
- x, y = turtle.inspect()
- if x == true then
- turtle.dig()
- end
- sleep(1)
- until x == false
- end
- function digUp()
- repeat
- x, y = turtle.inspectUp()
- if x == true then
- turtle.digUp()
- end
- sleep(1)
- until x == false
- end
- function digDown()
- repeat
- x, y = turtle.inspectDown()
- if x == true then
- turtle.digDown()
- end
- sleep(1)
- until x == false
- end
- function move(toMove)
- moved = 0
- while moved ~= toMove do
- repeat
- dig()
- x = turtle.forward()
- until x == true
- if rotation == 0 then
- Coordz = Coordz + 1
- elseif rotation == 1 then
- Coordx = Coordx - 1
- elseif rotation == 2 then
- Coordz = Coordz - 1
- elseif rotation == 3 then
- Coordx = Coordx + 1
- end
- moved = moved + 1
- end
- end
- function moveDown(toMove)
- moved = 0
- while moved ~= toMove do
- repeat
- digDown()
- x = turtle.down()
- until x == true
- Coordy = Coordy - 1
- moved = moved + 1
- end
- end
- function moveUp(toMove)
- moved = 0
- while moved ~= toMove do
- repeat
- digUp()
- x = turtle.up()
- until x == true
- Coordy = Coordy + 1
- moved = moved + 1
- end
- end
- function GoTo(x, y, z)
- if y - Coordy > 0 then
- moveUp(y - Coordy)
- else
- moveDown(-(y - Coordy))
- end
- if x - Coordx > 0 then
- while rotation ~= 3 do
- turnRight()
- end
- move(x - Coordx)
- else
- while rotation ~= 1 do
- turnRight()
- end
- move(-(x - Coordx))
- end
- if z - Coordz > 0 then
- while rotation ~= 0 do
- turnRight()
- end
- move(z - Coordz)
- else
- while rotation ~= 2 do
- turnRight()
- end
- move(-(z - Coordz))
- end
- end
- print("Go to x:")
- x = read()
- print("Go to y:")
- y = read()
- print("Go to z:")
- z = read()
- repeat
- GoTo(x, y, z)
- turtle.select(1)
- turtle.placeDown()
- sleep(15)
- digDown()
- GoTo(startX, startY, startZ)
- turtle.select(1)
- turtle.placeDown()
- sleep(15)
- digDown()
- until 1 == 0
- GoTo(oCoordx, oCoordy, oCoordz)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement