Advertisement
Mojokojo69

Untitled

Sep 8th, 2023 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. -- Assuming the speaker is on the right side of the computer
  2. local speaker = peripheral.find("speaker")
  3.  
  4. -- Function to play siren sound from a DFPWM file
  5. local function playSiren()
  6. local file = fs.open("siren.dfpwm", "rb")
  7. local audioData = file.readAll()
  8. file.close()
  9.  
  10. -- Convert string to table of bytes
  11. local audioTable = {}
  12. for i = 1, #audioData do
  13. local byte = string.byte(audioData, i, i)
  14. table.insert(audioTable, byte)
  15. end
  16.  
  17. speaker.playAudio(audioTable, 1)
  18. end
  19.  
  20. -- Play the siren for testing
  21. playSiren()
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement