Advertisement
hevohevo

CC: open_receive0

Apr 30th, 2016
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. -- open_receive0
  2. -- 遠隔操作で扉を開けるプログラム(メッセージ受信側)
  3.  
  4. local open_msg = "Open"  -- 開くメッセージ
  5.  
  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  -- もし受信メッセージが開くメッセージと同じならば、
  13.     print("correct")
  14.     redstone.setOutput("top", true)
  15.     os.sleep(10)
  16.     redstone.setOutput("top", false)
  17.   else  -- 同じでないならば、
  18.     print("wrong")
  19.   end
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement