hevohevo

CC: msg_receive0

Apr 30th, 2016
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 KB | None | 0 0
  1. -- msg_receive0
  2. -- ワイヤレス通信メッセージを受信する(受信側プログラム)
  3.  
  4. local mon = peripheral.wrap("top")  -- 上側のモニターを使います宣言
  5.  
  6. rednet.open("right")  -- 右側のモデムを使います宣言
  7.  
  8. while true do
  9.   local id, msg = rednet.receive()  -- メッセージを受信するまで待ち続ける
  10.  
  11.   print(id, msg)  --送信元IDとメッセージをターミナル画面に表示
  12.  
  13.   mon.clear()  -- モニターの表示リセット
  14.   mon.setCursorPos(1,1)  -- モニターのカーソル位置初期化
  15.   mon.write(msg)  -- 受信したメッセージを表示
  16. end
Add Comment
Please, Sign In to add comment