Advertisement
hevohevo

CC: open_receive1

May 2nd, 2016
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | None | 0 0
  1. -- open_receive1
  2. -- 遠隔操作で扉を開けるプログラム(メッセージ受信側)
  3.  
  4. local open_msg = "Open"  -- 開くメッセージ
  5. local close_msg = "Close"  -- 閉めるメッセージ
  6. rednet.open("right")  -- 右側に設置したモデムを使うという宣言
  7.  
  8. while true do
  9.   local id, msg = rednet.receive()  -- メッセージを待ち受ける
  10.   print(id, msg)
  11.  
  12.   if msg == open_msg then  -- もし受信メッセージが"Open"ならば、
  13.     redstone.setOutput("top", true)
  14.   elseif msg == close_msg then  -- もし受信メッセージが"Close"ならば、
  15.     redstone.setOutput("top", false)
  16.   else  -- どれでもなければ、
  17.     print("wrong")
  18.   end
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement