local sound_bank = {} function load_sounds_from(path) path = path or "res/mono" 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"), } sound_bank[filepath][1]:setRelative(true) sound_bank[filepath][1]:setPosition(0, 0, 0) end end end end function play_sound(path, x, y) 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 source:setPosition(x or 0, y or 0, 0) la.play(source) end