Prevent music from looping when jumping to another label ?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Gigan
Newbie
Posts: 13
Joined: Mon Jan 10, 2022 7:02 pm
Contact:

Prevent music from looping when jumping to another label ?

#1 Post by Gigan » Wed Feb 02, 2022 3:43 pm

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. :(

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

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

#2 Post by Alex » Wed Feb 02, 2022 4:42 pm

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

Gigan
Newbie
Posts: 13
Joined: Mon Jan 10, 2022 7:02 pm
Contact:

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

#3 Post by Gigan » Wed Feb 02, 2022 5:37 pm

Works like a charm ! Thank you so, so much ! :D

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], _ticlock_