Change main menu music during the game? [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
Hipi
Newbie
Posts: 8
Joined: Wed Aug 29, 2018 8:18 pm
Contact:

Change main menu music during the game? [Solved]

#1 Post by Hipi »

I can use persistent in screen so I can use different main menu pictures when I reach the different endings or points in the story... but I also want to change the menu music and I've tried all, but no one worked, if I set one specific music it won't change because an if/else statement... I don't know what to do, I need help

Thank you
Last edited by Hipi on Sat Sep 01, 2018 8:42 am, edited 1 time in total.

User avatar
Andredron
Miko-Class Veteran
Posts: 719
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Change main menu music during the game?

#2 Post by Andredron »

Random play music menu:
Option.rpy
define config.main_menu_music = renpy.random.shuffle(["music1.mp3", "music2.mp3", "music3.mp3", "music4.mp3"] )


Persistent:
Option.rpy

define config.main_menu_music = "heppiend" + persistent.last_t + ".ogg"

else

$ config.main_menu_music = "heppiend" + persistent.last_t + ".ogg

Last_t =1 will be heppiend1.ogg

User avatar
Hipi
Newbie
Posts: 8
Joined: Wed Aug 29, 2018 8:18 pm
Contact:

Re: Change main menu music during the game?

#3 Post by Hipi »

I have this error:

"coercing to Unicode: need string or buffer, NoneType found"

I tried putting persistant.menu = 1 and ="1" and none worked :(

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Change main menu music during the game?

#4 Post by IrinaLazareva »

Hipi wrote: Fri Aug 31, 2018 1:38 pm but I also want to change the menu music
There are several ways... Here one of them (Classical).

in options.rpy:

Code: Select all

define config.main_menu_music = None
somewhere in script (outside of label start):

Code: Select all

label main_menu:
    if persistent.musicon:
        $ renpy.music.play('new_music.mp3', channel='music', loop=True)
    else:
        $ renpy.music.play('old_music.mp3', channel='music', loop=True)
    jump main_menu_screen
for control, in main script:

Code: Select all

    $ persistent.musicon = True / False

User avatar
Hipi
Newbie
Posts: 8
Joined: Wed Aug 29, 2018 8:18 pm
Contact:

Re: Change main menu music during the game?

#5 Post by Hipi »

main_menu_screen is just an example? I have a label splashscreen, I tried doing this:

Code: Select all

 label splashscreen:

    scene black
    with Pause (1.5)

    show splash with dissolve
    with Pause(1.2)

    jump main_menu
    
label main_menu:
    if persistent.musicon:
        $ renpy.music.play("tl/menu2.mp3", channel='music', loop=True)
    else:
        $ renpy.music.play("tl/menu1.mp3", channel='music', loop=True)
    return
It works the change of music but... it starts the game immediately instead of enter in the main menu screen

User avatar
MaydohMaydoh
Regular
Posts: 165
Joined: Mon Jul 09, 2018 5:49 am
Projects: Fuwa Fuwa Panic
Tumblr: maydohmaydoh
Location: The Satellite of Love
Contact:

Re: Change main menu music during the game?

#6 Post by MaydohMaydoh »

Use the label "before_main_menu" instead.

User avatar
Hipi
Newbie
Posts: 8
Joined: Wed Aug 29, 2018 8:18 pm
Contact:

Re: Change main menu music during the game?

#7 Post by Hipi »

Thank you, it worked!!

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Change main menu music during the game?

#8 Post by IrinaLazareva »

Hipi wrote: Sat Sep 01, 2018 7:27 am main_menu_screen is just an example?
No. The special label's name, like before_main_menu
Hipi wrote: Sat Sep 01, 2018 7:27 am it starts the game immediately instead of enter in the main menu screen
splashscreen's block must be ended with return, not jump.
Here several examples: https://www.renpy.org/wiki/renpy/doc/co ... lashscreen
Hipi wrote: Sat Sep 01, 2018 8:42 am it worked!!
And this most important :)

Post Reply

Who is online

Users browsing this forum: Alex, Majestic-12 [Bot], piinkpuddiin