audio.Stop not working in my game.

Started by Matt_J95, Sat 06/02/2021 23:20:57

Previous topic - Next topic

Matt_J95

Hi,

Just started using AGS. Not a total noob to coding, did some basic Python before. Understand logic flow/parsing/indentation enough to get me started. Anyhows, I can't get a basic command to work in my game. When the character enters a room, the game should switch off the background ambient sound that was playing in the previous room. Speaking of which, the said ambient track plays just fine, using the eRepeat parameter. In terms of switching it off, should be Simple stuff, here is my code, which is placed in the Room script of the room where I want it switched off:

function room_AfterFadeIn()
{
  aRain_02.Stop();
}

Alas, this line of code does nothing when I walk into said room. The ambient noise keeps on playing on repeat without fail. I've tried removing the eRepeat parameter on the ambient background noise, to see if that had something to do with it. But no difference. Can anyone advise why it may not be working?

Cheers

Matt

Crimson Wizard

Just to double check , is this function properly linked to the room event? try putting something else there like "Display("I'm here!");" command and see if it runs.

Matt_J95

You've hit the nail on the head my friend. Tried to add Display(""); and that didn't work either. It must be what you mentioned that is the problem. How can I correct this? My other room scripts work fine. Also the square brackets {} seem ok, they are confirming yellow when I hit enter, and I'm not getting any error messages when I run the game.

Cheers

Matt

Crimson Wizard

Quote from: Matt_J95 on Sun 07/02/2021 00:37:57
You've hit the nail on the head my friend. Tried to add Display(""); and that didn't work either. It must be what you mentioned that is the problem. How can I correct this? My other room scripts work fine. Also the square brackets {} seem ok, they are confirming yellow when I hit enter, and I'm not getting any error messages when I run the game.

You have to connect functions to events, as explained in this tutorial:
https://adventuregamestudio.github.io/ags-manual/acintro3.html
https://adventuregamestudio.github.io/ags-manual/images/acintro3_05.png

Matt_J95

Thank you, having done it through the events panel, it now works fine. I'm baffled though, the script is the exact same as when I did it manually. It just pastes in the function for you instead of having to write it out. Why can't I just write it directly into the room script?

Cheers

Matt

Matt_J95

AHH ok I've worked out what's going on.

I'd managed to get the wrong spelling of Room Fade in from an older version of AGS making the function obselete. For some reason unlike other functions/commands it doesn't always autofill for you from a drop down box.

Many thanks for all the help, case is now solved.

SMF spam blocked by CleanTalk