local sound_bank = {} function load_sounds_from(path) path = path or "res/sound" local files = lf.getDirectoryItems(path) for _, file in ipairs(files) do local filepath = path.."/"..file if lf.getInfo(filepath).type == "directory" then load_sounds_from(filepath) else if is_filetype(filepath, {"wav", "ogg", "mp3"}) then sound_bank[filepath] = { size = 1, [1] = la.newSource(filepath, "static"), } end end end end function play_sound(path) sound = sound_bank[path] local source = nil for i = 1, sound.size do if not sound[i]:isPlaying() then source = sound[i] end end if not source then sound.size = sound.size + 1 sound[sound.size] = sound[1]:clone() source = sound[sound.size] end la.play(source) end