Skip to content

Commit

Permalink
fix some sounds not playing
Browse files Browse the repository at this point in the history
  • Loading branch information
marutypes committed Mar 19, 2023
1 parent f63aab8 commit 9d49df1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ Hooks.on("deleteCombat", () => {
if (settings.currentTheme == "none") {
return;
}

console.log(`Combat deleted`);
if (settings.endCombatSound) {
if (settings.playEndCombatSound) {
playRandomCombatSound(SOUND_TYPE.END_COMBAT);
}
});
5 changes: 5 additions & 0 deletions scripts/sounds.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ export function playRandomPlaylistSound(playlistName) {
if (playlist) {
// Select a random sound from the playlist
const playlistArray = Array.from(playlist.sounds);

if (playlistArray.length == 0) {
console.error(`Playlist ${playlistName} is empty :<`);
return;
}
const randomIndex = Math.floor(Math.random() * playlistArray.length);
const selectedSound = playlistArray[randomIndex];

Expand Down

0 comments on commit 9d49df1

Please sign in to comment.