updated sound

This commit is contained in:
2025-06-15 19:32:14 -04:00
parent 377c573a45
commit d6221293cb

View File

@@ -8,22 +8,9 @@ local function getFileName(name)
return fullFile return fullFile
end end
local function getSoundUrl(fileName)
local baseRoute = "https://git.astrocore.space/root/NovaCorpLLC/raw/branch/main/"
local name = getFileName(fileName)
local fullPath = baseRoute .. name
return fullPath
end
local function getSoundStream(fileName)
print("Getting sound stream for: " .. fileName)
local request = http.get(getSoundUrl(fileName))
print(textutils.serialize(request.getResponseHeaders()))
request.close()
end
local function playSound(speaker, fileName) local function playSound(speaker, fileName)
--local fileStream = getSoundStream(fileName)
local fileStream = getFileName(fileName) local fileStream = getFileName(fileName)
local values = io.lines(fileStream, 16 * 1024) local values = io.lines(fileStream, 16 * 1024)
for input in values do for input in values do
@@ -41,15 +28,26 @@ local function playControlRoomAlarm(speakers)
playSound(speakers,"short_control_alarm") playSound(speakers,"short_control_alarm")
end end
local function createSoundFile(fileName)
local baseRoute = "https://git.astrocore.space/root/NovaCorpLLC/raw/branch/main/"
local name = getFileName(fileName)
local fullPath = baseRoute .. name
shell.execute("rm", name)
local response = http.get(fullPath)
local fileData = response.readAll()
local file = fs.open(name,"w")
file.write(fileData)
file.close()
response.close()
end
function addSoundFile(fileName) function addSoundFile(fileName)
local baseRoute = "https://git.astrocore.space/root/NovaCorpLLC/raw/branch/main/" createSoundFile(fileName)
local name = getFileName(fileName)
local fullPath = baseRoute .. name
shell.execute("rm", name)
shell.execute("wget", fullPath)
end end
local function watch() local function watch()
@@ -59,7 +57,7 @@ end
local function startup() local function startup()
local sounds = { local sounds = {
{ fileName = "control_alarm" } { fileName = "short_control_alarm" }
} }
for i, item in ipairs(sounds) do for i, item in ipairs(sounds) do