Audio repeat

Started by Kaintoad, Sat 15/02/2025 00:16:27

Previous topic - Next topic

Kaintoad

Hi this is probably a dumb question but I can't find any help on it anywhere. I simply want an audio clip to repeat after fade in. The script with eRepeat doesn't repeat it. If I put it in rep_exec it repeats but messes the sound up.

function room_AfterFadeIn()
{
  aWindInside.Play(eRepeat);
//achantmausoleum.play();
if(player.PreviousRoom == 2){
  player.Walk(490, 444,  eBlock);
  player.FaceDirection(eDirectionDown);
}
}

function room_RepExec()
{
//awindinside.play(1);
}

Crimson Wizard

Here's the manual page on AudioClip.Play function:
https://adventuregamestudio.github.io/ags-manual/AudioClip.html#audioclipplay

This function has 2 parameters:
1. Priority
2. Repeating

You pass eRepeat as a first parameter, but that's a mistake.
The correct call would be:
Code: ags
aWindInside.Play(eAudioPriorityNormal, eRepeat);

I recommend checking out the manual first whenever a script command does not work as expected.
Also, autocomplete in the editor shows a tooltip about parameters when you type open bracket after function's name.

Kara Jo Kalinowski

Quote from: Crimson Wizard on Sat 15/02/2025 00:20:54Here's the manual page on AudioClip.Play function:
https://adventuregamestudio.github.io/ags-manual/AudioClip.html#audioclipplay

This function has 2 parameters:
1. Priority
2. Repeating

You pass eRepeat as a first parameter, but that's a mistake.
The correct call would be:
Code: ags
aWindInside.Play(eAudioPriorityNormal, eRepeat);

I recommend checking out the manual first whenever a script command does not work as expected.
Also, autocomplete in the editor shows a tooltip about parameters when you type open bracket after function's name.

I was in the process of typing the same thing - they might have gotten confused in reading that priority is an optional parameter. But you can't just ignore it, if you want to get to later optional parameters, unless there's a way I don't know about to indicate that in your function call.

Kaintoad

I had (eAudioPriority, eRepeat), as it says in the documentation. Where does it say to put Normal? I fixed it by making it 0.

Crimson Wizard

Quote from: Kaintoad on Sat 15/02/2025 02:08:23I had (eAudioPriority, eRepeat), as it says in the documentation. Where does it say to put Normal? I fixed it by making it 0.

The script you posted above does not contain a call with (eAudioPriority, eRepeat), but only with (eRepeat).

The manual gives a parameter list:
QuoteAudioClip.Play(optional AudioPriority, optional RepeatStyle)

The first parameter must be one of the AudioPriority enum values, another of RepeatStyle enum values. These enums can be found here:
https://adventuregamestudio.github.io/ags-manual/StandardEnums.html#audiopriority
https://adventuregamestudio.github.io/ags-manual/StandardEnums.html#repeatstyle

The proper way is to use one of these named values. eAudioPriorityNormal is just the default option for AudioPriority.

SMF spam blocked by CleanTalk