Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- local speaker = peripheral.wrap("bottom")
- local function alarm()
- for i = 0, 300, 2 do
- redstone.setAnalogOutput("back", 15)
- speaker.playNote("harp", 3, 4)
- os.sleep(0.5)
- redstone.setAnalogOutput("back", 0)
- os.sleep(0.5)
- end
- end
- local co = nil
- while true do
- local senderId, Message, protocol = rednet.receive("light_42", 300)
- if Message == true then
- redstone.setAnalogOutput("back", 15)
- elseif Message == false or Message == nil then
- redstone.setAnalogOutput("back", 0)
- elseif Message == "alarm" then
- if not co or coroutine.status(co) == "dead" then
- co = coroutine.create(alarm)
- coroutine.resume(co)
- end
- end
- os.sleep(0.1) -- Add a short delay to prevent constant looping
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement