Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modem = peripheral.wrap("left")
- modem.open(500)
- term.clear()
- term.setCursorPos(1,1)
- term.write("My X: ")
- x = tonumber(io.read())
- term.setCursorPos(1,2)
- term.write("My Y: ")
- y = tonumber(io.read())
- term.setCursorPos(1,3)
- term.write("My Z: ")
- z = tonumber(io.read())
- term.setCursorPos(1,4)
- term.write("Facing (xp/xn/zp/zn): ")
- facing = io.read()
- term.setCursorPos(1,5)
- term.write("Waiting for instructions...")
- term.setCursorPos(1,6)
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- px = tonumber(message)
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- py = tonumber(message)
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- pz = tonumber(message)
- notthere = true
- direction = "x"
- while notthere do
- if px > x and direction == "x" then
- if facing == "xn" then
- turtle.turnLeft()
- turtle.turnLeft()
- end
- if facing == "zp" then
- turtle.turnLeft()
- end
- if facing == "zn" then
- turtle.turnRight()
- end
- facing = "xp"
- turtle.dig()
- if turtle.forward() then
- x = x + 1
- end
- end
- if px < x and direction == "x" then
- if facing == "xp" then
- turtle.turnLeft()
- turtle.turnLeft()
- end
- if facing == "zp" then
- turtle.turnRight()
- end
- if facing == "zn" then
- turtle.turnLeft()
- end
- facing = "xn"
- turtle.dig()
- if turtle.forward() then
- x = x - 1
- end
- end
- if px == x and direction == "x" then
- direction = "z"
- end
- if pz > z and direction == "z" then
- if facing == "xn" then
- turtle.turnLeft()
- end
- if facing == "zn" then
- turtle.turnLeft()
- turtle.turnLeft()
- end
- if facing == "xp" then
- turtle.turnRight()
- end
- facing = "zp"
- turtle.dig()
- if turtle.forward() then
- z = z + 1
- end
- end
- if pz < z and direction == "z" then
- if facing == "xp" then
- turtle.turnLeft()
- end
- if facing == "zp" then
- turtle.turnLeft()
- turtle.turnLeft()
- end
- if facing == "xn" then
- turtle.turnRight()
- end
- turtle.dig()
- if turtle.forward() then
- z = z - 1
- end
- end
- if pz == z and direction == "z" then
- direction = "y"
- end
- if py > y and direction == "y" then
- turtle.digUp()
- if turtle.up() then
- y = y + 1
- end
- end
- if py < y and direction == "y" then
- turtle.digDown()
- if turtle.down() then
- y = y - 1
- end
- end
- if py == y and direction == "y" then
- notthere = false
- end
- end
- modem.transmit(500, 500, "Arrived")
Add Comment
Please, Sign In to add comment