- Joined
- Mar 23, 2023
- Messages
- 2
- Reaction score
- 0
var seconds = 0;
timedLoop(1000, function() {
seconds = seconds + 1;
console.log(seconds + " second(s)");
});
if (seconds == randomNumber(1, 20)) {
playSound("sound://category_accent/puzzle_game_accent_a_01.mp3", false);
}
The purpose of this function is to play sound at a random time while the timer initiates. The problem is that the playSound is repeated with the other variables, which is not content for my program. I have tried many ways to fix the issue, such as putting the playSound outside the function, but then the program never reaches or ignores the playSound since once it gets into the time loop function, it continually repeats itself. I have also tried putting a return function right above the playSound, so it doesn't repeat it, but it never reaches the playSound. If there are any suggestions, feel free to propose.
timedLoop(1000, function() {
seconds = seconds + 1;
console.log(seconds + " second(s)");
});
if (seconds == randomNumber(1, 20)) {
playSound("sound://category_accent/puzzle_game_accent_a_01.mp3", false);
}
The purpose of this function is to play sound at a random time while the timer initiates. The problem is that the playSound is repeated with the other variables, which is not content for my program. I have tried many ways to fix the issue, such as putting the playSound outside the function, but then the program never reaches or ignores the playSound since once it gets into the time loop function, it continually repeats itself. I have also tried putting a return function right above the playSound, so it doesn't repeat it, but it never reaches the playSound. If there are any suggestions, feel free to propose.