Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local alarm =false
- local note1 =peripheral.wrap("right")
- local note2 =peripheral.wrap("back")
- local wl = peripheral.wrap("top")
- wl.open(198)
- function play()
- while true do
- while alarm do
- note1.setPitch(23)
- note2.setPitch(23)
- note1.triggerNote()
- note2.triggerNote()
- sleep(1)
- note1.setPitch(24)
- note2.setPitch(24)
- note1.triggerNote()
- note2.triggerNote()
- sleep(1)
- end
- sleep(1)
- end
- end
- function receive()
- while true do
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- if senderChannel==198 then
- if message=="true" then
- alarm=true
- elseif message=="false" then
- alarm=false
- end
- end
- sleep(1)
- end
- end
- parallel.waitForAny(receive, play)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement