Music playback when jumping to label from main menu

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
User avatar
Rainvillain
Regular
Posts: 76
Joined: Thu Mar 05, 2015 11:27 am
Contact:

Music playback when jumping to label from main menu

#1 Post by Rainvillain »

Hello!

I made a button on my main menu so that I can jump to a later scene in my game. More specifically it's this button:

Code: Select all

textbutton _("convo") action Start("convo")
which brings me to a specific conversation in my scene that starts at the "convo" label.
My problem is that it isn't playing back my music tracks since the system was told to play the music tracks earlier on in the scene (in a previous label).

My game code looks something like this:

Code: Select all

# The game starts here.

label start:
    play music1 "guitar.ogg"
    play mixer2 "drums.ogg"
        
    c "blah blah blah"
    c "blah blah blah"

label convo:
    c "yo ho ho!"

So when you click on the button on my main menu that jumps you to the "convo" label, it skips over my command to play music and therefore has no music playing at all. (I've set up a second music channel btw, that is why I have a "music2" channel listed there).
My scene works fine if I start it from the very beginning using the action Start() command from the main menu.. it is just a case of when I jump to that specific label.

Is there a better way of having my Main Menu button jump to a certain part of a scene while retaining the audio/visual properties that were triggered right before that scene?

I should also stress that I'm a total newbie. And this is my first post! Hi, hello! I'm really enjoying Ren'py so far and finding it very intuitive, though I clearly have a lot to learn still.

User avatar
Arowana
Miko-Class Veteran
Posts: 531
Joined: Thu May 31, 2012 11:17 pm
Completed: a2 ~a due~
Projects: AXIOM.01, The Pirate Mermaid
Organization: Variable X, Navigame
Tumblr: navigame-media
itch: navigame
Contact:

Re: Music playback when jumping to label from main menu

#2 Post by Arowana »

Hi, Rainvillain! Welcome to Ren'Py and glad to hear you are enjoying it so far. :D

If you start the game from a random scene ("convo"), I don't think there is any way for it to know what happened in another scene you didn't actually play ("start"). I think you'd have to tell it to play the music at the beginning of the "convo" label as well.

If you're worried about the music restarting if you did play through from "start" originally, you can check what song is currently playing. Something like this, maybe?

Code: Select all

    
if renpy.music.get_playing() != song:
    play music song
Hope I understood what you're trying to do. ^^
Complete: a2 ~a due~ (music, language, love)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)

Image

User avatar
Rainvillain
Regular
Posts: 76
Joined: Thu Mar 05, 2015 11:27 am
Contact:

Re: Music playback when jumping to label from main menu

#3 Post by Rainvillain »

Hi there! Thanks for the help! Yes, that solved my problem... :)

Post Reply

Who is online

Users browsing this forum: No registered users