Music in menu problem -solved

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
Kindynos
Newbie
Posts: 23
Joined: Wed Feb 06, 2013 10:42 pm
Projects: Artist's Heart
Location: Santiago, Chile
Contact:

Music in menu problem -solved

#1 Post by Kindynos »

So, I'm fairly new to this, and I've been working nonstop on what I'm doing, I read the tutorials and all.
Also I am really sorry if I put this post in the wrong place ;;

I put music in the title screen, it worked fine but when starting the game, the music keeps playing, and I'm not sure how to make it stop after I press "Start game" I've looked for it around the tutorials and all, but I seem to not find it
Any help? Code or anything? It's the only thing I have to do to have a descent start, I think.

Also, I want to do something like. . "easter egg", after a while, the title screen changes to another picture and the music changes, is that possible? if so, how? I know it's unrelated but I don't really like making many topic on forums ;
Last edited by Kindynos on Sun Feb 10, 2013 2:29 am, edited 1 time in total.

User avatar
Greeny
Miko-Class Veteran
Posts: 921
Joined: Sun Dec 20, 2009 10:15 am
Completed: The Loop, The Madness
Projects: In Orbit, TBA
Organization: Gliese Productions
Location: Cantankerous Castle
Contact:

Re: Music in menu problem

#2 Post by Greeny »

Code: Select all

label start:
    stop music fadeout 2.0
The fadeout clause will cause it not to stop suddenly. 2.0 gives the amount of seconds it takes.
I'd say it's optional, but rather important - I find that when entering the game from the main menu, it always feel awkward when I forget to put fadeout.

Having the main menu change is easier if you use a label for the main menu.

Code: Select all

label main_menu:
    if persistent.change:
        scene bg alternative_menu
        play music "alt.mp3"
    else:
        scene bg menu_base
        play music "base.mp3"
    call screen main_menu
You'll also need to remove the background from your actual main menu screen, so it show what's behind it.
Go to screens.rpy and find the bit that says

Code: Select all

screen main_menu:
    tag menu
    
    window:
        style "mm_root"
And put "#" in front of the "window" and "style"
Don't forget to define your background images in an image statement. Now you just need to pick a moment in your script to make the change happen:

Code: Select all

$ persistent.change = True
I should note that this is only one of many possible ways to achieve this.
In Orbit [WIP] | Gliese is now doing weekly erratic VN reviews! The latest: Halloween Otome!
Gliese Productions | Facebook | Twitter
Image

User avatar
Kindynos
Newbie
Posts: 23
Joined: Wed Feb 06, 2013 10:42 pm
Projects: Artist's Heart
Location: Santiago, Chile
Contact:

Re: Music in menu problem

#3 Post by Kindynos »

Oh, thank you! The music stopped and all, that was really helpful ~~ Thank you a lot.

For the second one, okay, I did everything- My only problem is, how do I define how much time will have to pass 'till it changes? I am obviously a noob- I'm sorry about that

User avatar
Greeny
Miko-Class Veteran
Posts: 921
Joined: Sun Dec 20, 2009 10:15 am
Completed: The Loop, The Madness
Projects: In Orbit, TBA
Organization: Gliese Productions
Location: Cantankerous Castle
Contact:

Re: Music in menu problem

#4 Post by Greeny »

Oh, you mean, after a certain time waiting in the menu?
That's a different matter altogether.
Forget persistent.change.
You'll want to define a timer in your screens.rpy file:

Code: Select all

screen mm_timer:
    timer length action Jump("main_menu_change")
And for your main menu, use these labels:

Code: Select all

label main_menu:
    if mm_change:
        scene bg alternative_menu
        play music "alt.mp3"
    else:
        scene bg menu_base
        play music "base.mp3"
    show screen mm_timer(length=60.0) 
    call screen main_menu

label main_menu_change:
    $ mm_change = True
    jump main_menu
Where it says length=60.0, you can change that number to determine the amount of seconds it will take to change the menu.
In Orbit [WIP] | Gliese is now doing weekly erratic VN reviews! The latest: Halloween Otome!
Gliese Productions | Facebook | Twitter
Image

User avatar
Kindynos
Newbie
Posts: 23
Joined: Wed Feb 06, 2013 10:42 pm
Projects: Artist's Heart
Location: Santiago, Chile
Contact:

Re: Music in menu problem

#5 Post by Kindynos »

I feel like a bother, I'm really sorry if I'm bothering with the questions

But now it tells me 'mm_change' is not defined.

Of course, I must have done something wrong, but what?

User avatar
Greeny
Miko-Class Veteran
Posts: 921
Joined: Sun Dec 20, 2009 10:15 am
Completed: The Loop, The Madness
Projects: In Orbit, TBA
Organization: Gliese Productions
Location: Cantankerous Castle
Contact:

Re: Music in menu problem

#6 Post by Greeny »

Oh, right. General rule: If it says it's not defined, define it!

Code: Select all

init:
    $ mm_change = False
In Orbit [WIP] | Gliese is now doing weekly erratic VN reviews! The latest: Halloween Otome!
Gliese Productions | Facebook | Twitter
Image

User avatar
Kindynos
Newbie
Posts: 23
Joined: Wed Feb 06, 2013 10:42 pm
Projects: Artist's Heart
Location: Santiago, Chile
Contact:

Re: Music in menu problem

#7 Post by Kindynos »

Mm, no, it's giving me the same thing, even if defined.


I'm sorry, but an uncaught exception occurred.
While running game code:
File "game\script.rpy", line 6, in script
File "game\script.rpy", line 6, in python
NameError: name 'mm_change' is not defined

-- Full Traceback ------------------------------------------------------------

Full traceback:
File "C:\-\-\Artist's Heart\Renpy\renpy-6.14.1-sdk\renpy\execution.py", line 266, in run
File "C:\-\-\Artist's Heart\Renpy\renpy-6.14.1-sdk\renpy\ast.py", line 1394, in execute
File "C:\-\-\Artist's Heart\Renpy\renpy-6.14.1-sdk\renpy\python.py", line 1206, in py_eval
File "game\script.rpy", line 6, in <module>
NameError: name 'mm_change' is not defined

Windows-7-6.1.7600
Ren'Py 6.14.1.366
Artist's heart 0.0
And this is the code that I have at the start of the script

Code: Select all

image bg alternative_menu = "Menu2.png"
image bg menu_base = "Menu1.png"

label main_menu:
    if mm_change:
        scene bg alternative_menu
        play music "Second title.mp3"
    else:
        scene bg menu_base
        play music "First title.mp3"
    show screen mm_timer(length=60.0)
    call screen main_menu

label main_menu_change:
    $ mm_change = False
    jump main_menu
But I think that my problem is the other code

Code: Select all

screen mm_timer:
    timer length action Jump("main_menu_change")
I think I'm having a problem with that one, or not ;; I'm not really sure.

User avatar
Greeny
Miko-Class Veteran
Posts: 921
Joined: Sun Dec 20, 2009 10:15 am
Completed: The Loop, The Madness
Projects: In Orbit, TBA
Organization: Gliese Productions
Location: Cantankerous Castle
Contact:

Re: Music in menu problem

#8 Post by Greeny »

No, you changed it wrong.

Code: Select all

image bg alternative_menu = "Menu2.png"
image bg menu_base = "Menu1.png"

init:
    $ mm_change = False

label main_menu:
    if mm_change:
        scene bg alternative_menu
        play music "Second title.mp3"
    else:
        scene bg menu_base
        play music "First title.mp3"
    show screen mm_timer(length=60.0)
    call screen main_menu

label main_menu_change:
    $ mm_change = True
    jump main_menu
In Orbit [WIP] | Gliese is now doing weekly erratic VN reviews! The latest: Halloween Otome!
Gliese Productions | Facebook | Twitter
Image

User avatar
Kindynos
Newbie
Posts: 23
Joined: Wed Feb 06, 2013 10:42 pm
Projects: Artist's Heart
Location: Santiago, Chile
Contact:

Re: Music in menu problem

#9 Post by Kindynos »

There it is!! Thank you very much! I'm sorry for being a bother huh- But still, thank you a lot!!

Post Reply

Who is online

Users browsing this forum: Google [Bot]