Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.find("monitor")
- local speaker = peripheral.find("speaker")
- local modem = peripheral.find("modem")
- local drive = peripheral.find("drive")
- local dfpwm = require("cc.audio.dfpwm")
- local decoder = dfpwm.make_decoder()
- local repeattime = 10
- local event, id
- local mail
- local defaultsong="/startup/youve-got-mail-sound.dfpwm"
- song=defaultsong
- if drive.isDiskPresent then
- print("Disk present")
- if fs.find("/disk/*.dfpwm") then
- floppysong=fs.find("/disk/*.dfpwm")
- song=floppysong[1]
- print("Floppy Song is ", song)
- end
- end
- if song==nil then
- song=defaultsong
- end
- print("Song is ", song)
- modem.open(42)
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.write("Checking for mail")
- modem.transmit(42, 42, "Checking for mail")
- os.startTimer(repeattime)
- while true do
- local eventData = {os.pullEvent()}
- event = eventData[1]
- if event == "redstone" then
- monitor.clear()
- monitor.setCursorPos(1,1)
- if redstone.getInput("bottom") then
- mail = true
- monitor.write("You've got Mail")
- modem.transmit(42, 42, "You've got Mail")
- --play audio
- for chunk in io.lines(song, 16 * 1024) do
- local buffer = decoder(chunk)
- while not speaker.playAudio(buffer,128) do
- os.pullEvent("speaker_audio_empty")
- end
- end
- os.startTimer(repeattime)
- else
- mail = false
- monitor.write("Checking for mail")
- modem.transmit(42, 42, "Checking for mail")
- end
- elseif event == "timer" then
- if redstone.getInput("bottom") then
- --play audio
- for chunk in io.lines(song, 16 * 1024) do
- local buffer = decoder(chunk)
- while not speaker.playAudio(buffer,128) do
- os.pullEvent("speaker_audio_empty")
- end
- end
- os.startTimer(repeattime)
- else
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.write("Checking for mail")
- modem.transmit(42, 42, "Checking for mail")
- end
- elseif event == "disk_eject" then
- song=defaultsong
- print("Song is ", song)
- elseif event == "disk" then
- if fs.find("/disk/*.dfpwm") then
- floppysong=fs.find("/disk/*.dfpwm")
- song=floppysong[1]
- print("Floppy Song is ", song)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement