Page 1 of 1

Prevent music from looping when jumping to another label ?

Posted: Wed Feb 02, 2022 3:43 pm
by Gigan
I'm sorry for such a noob question, but the documentation is a bit too hard to understand, with my limited english. :(

I'm making a point and click, and the main village is composed of 4 different screens. Since the player can access those 4 screens in any order, each label starts with a play music "audio/village.wav".

Problem is, if the player is like, on a first screen of the village and want to jump to a second screen, the music "village.wav" starts back at the beginning, since the 2nd map also has a play music "audio/village.wav" code. I understand where the problem is, I just have no idea how to fix it.

So question is, is there a piece of code I can use so the play music "audio/village.wav" is ignored if that piece of music specifically is already playing ?

Again, the solution is probably pretty simple, so sorry about that. I've been trying to resolve the issue alone with the past 2 days. :(

Re: Prevent music from looping when jumping to another label ?

Posted: Wed Feb 02, 2022 4:42 pm
by Alex
Gigan wrote:
Wed Feb 02, 2022 3:43 pm
...So question is, is there a piece of code I can use so the play music "audio/village.wav" is ignored if that piece of music specifically is already playing ?...
Try to play your music like

Code: Select all

$ renpy.music.play("audio/village.wav", "music", if_changed=True)
https://www.renpy.org/doc/html/audio.ht ... music.play

Re: Prevent music from looping when jumping to another label ?

Posted: Wed Feb 02, 2022 5:37 pm
by Gigan
Works like a charm ! Thank you so, so much ! :D