Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open ("right")
- PCID = 21
- orientation = 1
- orientations = {"north", "east", "south", "west"}
- xCoord = 0
- zCoord = 0
- yCoord = 0
- zDiff = {-1, 0, 1, 0}
- xDiff = {0, 1, 0, -1}
- local function left()
- orientation = orientation - 1
- orientation = (orientation - 1) % 4
- orientation = orientation + 1
- turtle.turnLeft()
- end
- local function right()
- orientation = orientation - 1
- orientation = (orientation + 1) % 4
- orientation = orientation + 1
- turtle.turnRight()
- end
- local function moveForward()
- xCoord = xCoord + xDiff[orientation]
- zCoord = zCoord + zDiff[orientation]
- while turtle.detect() do
- turtle.dig()
- end
- moved = false
- while not(moved) do
- moved = turtle.forward()
- end
- end
- local function moveUp()
- yCoord = yCoord + 1
- turtle.digUp()
- moved = false
- while not(moved) do
- moved = turtle.up()
- end
- end
- local function moveDown()
- yCoord = yCoord - 1
- turtle.digDown()
- moved = false
- while not(moved) do
- moved = turtle.down()
- end
- end
- local function moveBack()
- left()
- left()
- moveForward()
- left()
- left()
- end
- local function checkorder(command)
- if command == "go" then
- moveForward()
- elseif command == "back" then
- moveBack()
- elseif command == "left" then
- left()
- elseif command == "right" then
- right()
- elseif command == "dig" then
- turtle.dig()
- elseif command == "up" then
- moveUp()
- elseif command == "down" then
- moveDown()
- elseif command == "place" then
- turtle.place()
- elseif command == "digup" then
- turtle.digUp()
- elseif command == "digdown" then
- turtle.digDown()
- elseif command == "placeup" then
- turtle.placeUp()
- elseif command == "placedown" then
- turtle.placeDown()
- end
- end
- while true do
- id, com = rednet.receive()
- checkorder(com)
- sleep(1)
- print("I am at X: " ..xCoord.. " Z: " ..zCoord.. "Y " ..yCoord)
- end
Advertisement
Add Comment
Please, Sign In to add comment