53 lines
1.3 KiB
Lua
53 lines
1.3 KiB
Lua
-- Random Audio Player
|
|
-- Simplified version that only plays random audio files
|
|
|
|
local COLORS = {
|
|
INFO = colors.white,
|
|
WARN = colors.yellow,
|
|
WARNING = colors.yellow,
|
|
ERROR = colors.red,
|
|
DEBUG = colors.cyan,
|
|
SUCCESS = colors.green
|
|
}
|
|
|
|
-- Debug output function
|
|
local function debugPrint(level, message)
|
|
local timestamp = os.date("%H:%M:%S")
|
|
local logMessage = string.format("[%s][%s] %s", timestamp, level, message)
|
|
local color = COLORS[level] or colors.white
|
|
local oldColor = term.getTextColor()
|
|
term.setTextColor(color)
|
|
print(logMessage)
|
|
term.setTextColor(oldColor)
|
|
end
|
|
|
|
-- Add random audio playback function
|
|
local function playRandomAudio()
|
|
local audioFiles = {"aqtx", "jzxy"}
|
|
local randomFile = audioFiles[math.random(#audioFiles)]
|
|
local path = "/Audio/"..randomFile..".dfpwm"
|
|
|
|
if fs.exists(path) then
|
|
debugPrint("INFO", "Attempting to play: "..path)
|
|
shell.run("austream "..path.." volume=3.0")
|
|
debugPrint("INFO", "Finished playing: "..randomFile)
|
|
else
|
|
debugPrint("ERROR", "Audio file not found: "..path)
|
|
end
|
|
end
|
|
|
|
-- Main loop
|
|
local elapsedSeconds = 0
|
|
while true do
|
|
if elapsedSeconds >= 240 then
|
|
playRandomAudio()
|
|
elapsedSeconds = 0
|
|
end
|
|
|
|
os.sleep(1)
|
|
elapsedSeconds = elapsedSeconds + 1
|
|
end
|
|
|
|
|
|
|