From cf8ba16eb19c01a93bfc227fe643229cd4160ed9 Mon Sep 17 00:00:00 2001 From: MarkGamed7794 <47731570+MarkGamed7794@users.noreply.github.com> Date: Thu, 16 Sep 2021 21:56:35 -0400 Subject: [PATCH] Remove the print statement and also fix a logic issue --- load/sounds.lua | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/load/sounds.lua b/load/sounds.lua index 6e3e1f8..6e03b1f 100644 --- a/load/sounds.lua +++ b/load/sounds.lua @@ -1,4 +1,4 @@ -sounds = { +sound_paths = { blocks = { I = "res/se/piece_i.wav", J = "res/se/piece_j.wav", @@ -33,25 +33,22 @@ sounds = { welcome = "res/se/welcomeToCambridge.wav", } +sounds = {} -- Replace each sound effect string with its love audiosource counterpart, but only if it exists. This lets the game handle missing SFX. -for k,v in pairs(sounds) do +for k,v in pairs(sound_paths) do if(type(v) == "table") then -- list of subsounds for k2,v2 in pairs(v) do - if(love.filesystem.getInfo(sounds[k][k2])) then + if(love.filesystem.getInfo(sound_paths[k][k2])) then -- this file exists - sounds[k][k2] = love.audio.newSource(sounds[k][k2], "static") - else - sounds[k][k2] = nil + sounds[k] = sounds[k] or {} + sounds[k][k2] = love.audio.newSource(sound_paths[k][k2], "static") end end else - if(love.filesystem.getInfo(sounds[k])) then + if(love.filesystem.getInfo(sound_paths[k])) then -- this file exists - print("Successfully converted " .. v) - sounds[k] = love.audio.newSource(sounds[k], "static") - else - sounds[k] = nil + sounds[k] = love.audio.newSource(sound_paths[k], "static") end end end