How do you stop music from looping, without causing rollback to stop playing music, & ensure music plays after loading?

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
henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

How do you stop music from looping, without causing rollback to stop playing music, & ensure music plays after loading?

#1 Post by henvu50 »

I'm trying to simply play music without it looping. But, if you set the music playing loop to False in ANYWAY, it causes two problems:

Problem #1. If you rollback, the music stops playing.
Problem #2. If you load a save game, the music no longer plays.

However, if you set the music loop to True, in anyway, then the above two problems no longer occur, but now you're stuck with annoying music that loops over & over again.

So, how do you stop music looping, but without the above 2 problems from occurring?

User avatar
m_from_space
Miko-Class Veteran
Posts: 939
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: How do you stop music from looping, without causing rollback to stop playing music, & ensure music plays after loadi

#2 Post by m_from_space »

I don't know about the rollback, but you could work around the loading problem by having a global variable keeping track of the current music.

Code: Select all

default background_music = "None"

label after_load:
	if background_music != "None":
		play music background_music fadein 1.0 noloop
	return

label start:
	$ background_music = "audio/mymusic.mp3"
	play music background_music
	...

Post Reply

Who is online

Users browsing this forum: No registered users