Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Move(direction, steps)
- if direction == "frwd" then
- for i= 1, steps, 1 do
- turtle.forward()
- end
- elseif direction == "back" then
- for i= 1, steps, 1 do
- turtle.back()
- end
- elseif direction == "up" then
- for i = 1, steps, 1 do
- turtle.up()
- end
- elseif direction == "down" then
- for i = 1, steps, 1 do
- turtle.down()
- end
- else
- error("err: invalid direction")
- end
- end
- function Turn(direction, steps)
- if direction == "left" then
- for i = 1, steps, 1 do
- turtle.turnLeft()
- end
- elseif direction == "right" then
- for i = 1, steps, 1 do
- turtle.turnRight()
- end
- else
- error("err: invalid direction")
- end
- end
- local modem = peripheral.wrap("left")
- modem.open(1)
- while true do
- local event,
- modemSide,
- senderChannel,
- replyChannel,
- message,
- senderDistance = os.pullEvent("modem_message")
- if message == "end" then
- break
- elseif message == "frwd" then
- Move("frwd", 1)
- elseif message == "back" then
- Move("back", 1)
- else
- error("err: invalid command")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement