Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dfpwm = require("cc.audio.dfpwm")
- local speaker = peripheral.find("speaker")
- local function playDFPWMAudio(fileName) --Code from https://tweaked.cc/peripheral/speaker.html#v:playAudio.
- local decoder = dfpwm.make_decoder()
- for chunk in io.lines(fileName, 16 * 1024) do
- local buffer = decoder(chunk)
- while not speaker.playAudio(buffer) do
- os.pullEvent("speaker_audio_empty")
- end
- end
- end
- while true do
- term.clear()
- term.setCursorPos(1, 1)
- term.write("Password: ")
- local input = read("*")
- term.clear()
- term.setCursorPos(1, 1)
- if input == "1111" then
- print("Welcome home!")
- rs.setOutput("back", true)
- sleep(3)
- rs.setOutput("back", false)
- else
- print("ERROR")
- playDFPWMAudio("placeholder.dfpwm") --Change this to the name of the DFPWM audio file.
- sleep(2)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment