Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xCoord = -178
- yCoord = 81
- zCoord = 157
- zDiff = {-1, 0, 1, 0}
- xDiff = {0, 1, 0, -1}
- orientation = 4
- orientations = {"north", "east", "south", "west"}
- function left()
- orientation = orientation - 1
- orientation = (orientation - 1) % 4
- orientation = orientation + 1
- turtle.turnLeft()
- end
- function right()
- orientation = - 1
- orientation = (orientation + 1) % 4
- orientation = orientation + 1
- turtle.turnRight()
- end
- function moveForward()
- xCoord = xCoord + xDiff[orientation]
- zCoord = zCoord + zDiff[orientation]
- turtle.dig()
- moved = false
- while not(moved) do
- moved = turtle.forward()
- moved = print("I Tried to move")
- end
- print("I moved :D")
- end
- function.moveUp()
- yCoord = yCoord + 1
- turtle.digUp()
- moved = false
- while not(moved) do
- moved = turtle.up()
- end
- end
- function moveDown()
- yCoord = yCoord - 1
- turtle.digDown()
- moved = false
- while not(moved) do
- turtle.down()
- end
- end
- function look(direction)
- while direction ~=orientations[orientation] do
- right()
- end
- end
- function goto(xTarget, zTarget, yTarget)
- while yTarget < yCoord do
- moveDown()
- end
- while yTarget > yCoord do
- moveUp()
- end
- end
- if xTarget < xCoord then
- look("west")
- while xTarget > xCoord do
- moveForward()
- end
- end
- if zTarget < zCoord then
- look("north")
- while zTarget < zCoord do
- moveForward()
- end
- end
- if zTarget > zCoord then
- look("south")
- while zTarget > zCoord do
- moveForward()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement