Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- rc_receive0
- -- ラジコンプログラム(タートル側)
- -- Config
- local left_msg = "strafe_left"
- local right_msg = "strafe_right"
- local forward_msg = "go_forward"
- local back_msg = "go_back"
- -- Functions
- function strafeRight()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- end
- function strafeLeft()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- end
- -- Main
- rednet.open("left") -- 左側に設置したモデムを使うという宣言
- while true do
- local id, msg = rednet.receive() -- メッセージを待ち受ける
- print(id, msg)
- if msg == left_msg then
- strafeLeft()
- elseif msg == right_msg then
- strafeRight()
- elseif msg == forward_msg then
- turtle.forward()
- elseif msg == back_msg then
- turtle.back()
- else -- どれでもなければ、
- print("wrong")
- end
- end
Add Comment
Please, Sign In to add comment