Cod0fDuty

CC: Tweaked Password Door

Nov 23rd, 2024
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | Source Code | 0 0
  1. local dfpwm = require("cc.audio.dfpwm")
  2. local speaker = peripheral.find("speaker")
  3.  
  4. local function playDFPWMAudio(fileName)     --Code from https://tweaked.cc/peripheral/speaker.html#v:playAudio.
  5.     local decoder = dfpwm.make_decoder()
  6.     for chunk in io.lines(fileName, 16 * 1024) do
  7.         local buffer = decoder(chunk)
  8.         while not speaker.playAudio(buffer) do
  9.             os.pullEvent("speaker_audio_empty")
  10.         end
  11.     end
  12. end
  13.  
  14. while true do
  15.     term.clear()
  16.     term.setCursorPos(1, 1)
  17.     term.write("Password: ")
  18.     local input = read("*")
  19.     term.clear()
  20.     term.setCursorPos(1, 1)
  21.     if input == "1111" then
  22.         print("Welcome home!")
  23.         rs.setOutput("back", true)
  24.         sleep(3)
  25.         rs.setOutput("back", false)
  26.     else
  27.         print("ERROR")
  28.         playDFPWMAudio("placeholder.dfpwm")     --Change this to the name of the DFPWM audio file.
  29.         sleep(2)
  30.     end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment