Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ###############################
- -- msg_sender
- rednet.open("left")
- local dest_id = 18
- local my_id = os.getComputerID()
- local msg1 = "turtle.turnRight()"
- local msg2 = "turtle.turnLeft()"
- local msg = ""
- function mysend(dest_id, msg)
- for i=1,5 do
- print(i,":sending to ",dest_id )
- rednet.send(dest_id, msg)
- print(i,': wait')
- local res = {rednet.receive(1)}
- if res and res[2] == msg then return true end
- end
- return false
- end
- while true do
- local event, key_code = os.pullEvent("key")
- local key = keys.getName(key_code)
- if key == "left" then
- msg = msg2
- elseif key == "right" then
- msg = msg1
- else
- error("hoge")
- end
- print("sending...: ", msg)
- if mysend(dest_id, msg) then
- print("succeeded: ", msg)
- func = loadstring(msg)
- func()
- else
- print("failed: ", msg)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement