Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- open_send1
- -- 遠隔操作で扉を開けるプログラム(メッセージ送信、リモコン側)
- -- Config
- local id = 65535 -- 送信先ID
- local open_msg = "Open" -- 開くメッセージ
- local close_msg = "Close" -- 閉めるメッセージ
- -- Functions
- function init()
- term.clear()
- term.setCursorPos(1,1)
- print("[o]pen")
- print("[c]lose")
- print("[q]uit")
- end
- -- Main
- rednet.open("back") -- ポケットコンピュータは後ろ側にモデムがある
- while true do
- init()
- local event, moji = os.pullEvent("char")
- print(moji)
- if moji == "o" then -- もしmojiが"o"ならば、
- print("send msg: [Open]")
- rednet.send(id, open_msg) -- Openメッセージを送信
- elseif moji == "c" then -- もしmojiが"c"ならば、
- print("send msg: [Close]")
- rednet.send(id, close_msg) -- Closeメッセージを送信
- elseif moji == "q" then -- もし mojiが"q"ならば、
- print("quit program")
- break -- while無限ループを抜け出す
- else -- そうでなければ、
- print("wrong moji")
- end
- os.sleep(2)
- end
Add Comment
Please, Sign In to add comment