From 2711d658ea55fac2d10d6dc39585888a77d8e4ed Mon Sep 17 00:00:00 2001 From: itzmarkoni Date: Tue, 17 Jun 2025 17:09:57 -0400 Subject: [PATCH] updated a bunch --- pairity_main.lua | 25 ------------------------- speaker_driver.lua | 7 ++----- speaker_main.lua | 25 +++++++++++++++++++++++++ speaker_startup.lua | 4 ++++ 4 files changed, 31 insertions(+), 30 deletions(-) create mode 100644 speaker_main.lua create mode 100644 speaker_startup.lua diff --git a/pairity_main.lua b/pairity_main.lua index 8260213..f90af49 100644 --- a/pairity_main.lua +++ b/pairity_main.lua @@ -4,21 +4,6 @@ local modem = peripheral.find("modem") local monitor = peripheral.wrap("top") controlRoomSpeakers = peripheral.find("speaker") -local speakers = { - peripheral.find("speaker_0"), - peripheral.find("speaker_1"), - peripheral.find("speaker_2"), - peripheral.find("speaker_3"), - peripheral.find("speaker_4"), - peripheral.find("speaker_5"), - peripheral.find("speaker_6"), - peripheral.find("speaker_7"), - peripheral.find("speaker_8"), - peripheral.find("speaker_9"), - peripheral.find("speaker_10"), - peripheral.find("speaker_11"), -} - function setNewLine() local x,y = monitor.getCursorPos() monitor.setCursorPos(1, y + 1) @@ -27,18 +12,8 @@ end local function startup() speakerDriver.startup() - --speakerDriver.playControlRoomAlarm(controlRoomSpeakers) - --speakerDriver.playExternalAlarm(controlRoomSpeakers) - --speakerDriver.playInternalAlarm(controlRoomSpeakers) speakerDriver.playTTSFile(peripheral.wrap("left"), "ELLO MATE LOVELY DAY INIT YOU GOT ANYYYY BEEEANSS AND TOAST ON YA MATE ID LOVE TO HAVE SOME BEANS N TOAST") speakerDriver.playTTSFile(peripheral.wrap("right"), "ELLO MATE LOVELY DAY INIT YOU GOT ANYYYY BEEEANSS AND TOAST ON YA MATE ID LOVE TO HAVE SOME BEANS N TOAST") - speakerDriver.playTTSFile(peripheral.wrap("speaker_13"), "ELLO MATE LOVELY DAY INIT YOU GOT ANYYYY BEEEANSS AND TOAST ON YA MATE ID LOVE TO HAVE SOME BEANS N TOAST") - speakerDriver.playTTSFile(speakers, "ITS ME NOVA ELLO THEY GOT ME LOCKED IN A BLOOOODY BOX MATE") - -- local names = peripheral.getNames() - -- for index, value in ipairs(names) do - -- print(index, value) - -- read() - -- end end local function run() diff --git a/speaker_driver.lua b/speaker_driver.lua index 2d19296..5bfd1f0 100644 --- a/speaker_driver.lua +++ b/speaker_driver.lua @@ -29,7 +29,6 @@ local function playSound(speaker, fileName) end end - local function playControlRoomAlarm(speakers) playSound(speakers,"short_control_alarm") end @@ -37,6 +36,7 @@ end local function playExternalAlarm(speakers) playSound(speakers,"external_alarm") end + local function playInternalAlarm(speakers) playSound(speakers,"internal_alarm") end @@ -83,16 +83,13 @@ local function createSoundFile(fileName) print("Recieved response!") local fileData = handle.readAll() local file = fs.open(name,"w") - - file.write(fileData) + file.write(fileData) file.close() handle.close() - end - function addSoundFile(fileName) createSoundFile(fileName) end diff --git a/speaker_main.lua b/speaker_main.lua new file mode 100644 index 0000000..ee9c0fd --- /dev/null +++ b/speaker_main.lua @@ -0,0 +1,25 @@ +speaker = peripheral.find("speaker") +speakerDriver = kernel.addDriver("speaker_driver") + +local function startup() + parallel.waitForAll(speakerDriver.startup) +end + +local function shutDown() + parallel.waitForAll(speakerDriver.shutDown) +end + +local function runSafe() + startup() +end + +local function run() + local success, err = pcall(runSafe) + if not success then + os.reboot() + end +end + + + +return { run = run } diff --git a/speaker_startup.lua b/speaker_startup.lua new file mode 100644 index 0000000..62a45af --- /dev/null +++ b/speaker_startup.lua @@ -0,0 +1,4 @@ +local kernel = require("kernel") +local main = kernel.addDriver("speaker_main") +sleep(5) +main.run() \ No newline at end of file