Play music in menu "on replace"

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
User avatar
Posts: 105
Joined: Wed Mar 28, 2018 5:54 pm

Play music in menu "on replace"

#1 Post by kostek00 » Fri May 11, 2018 2:58 pm

In my main menu screen I have:

Code: Select all

on "replace" action Play("music", "bgm/M01.ogg")
Which is fine but I saw one problem. Every time I'm going into main menu music is beeing replaced weather I exit game or come from menu item (load, options, etc.). How could I make it so it will only replace music if I enter main menu by exiting game and not by moving around menu?

I tried something like that but it doesn't seem to work:

Code: Select all

if not main_menu:
	on "replace" action Play("music", "bgm/M01.ogg")
Whole main_menu:

Code: Select all

screen main_menu:
    tag menu
    add "images/gui/gui_ground.png"
    add "images/gui/title.png"

        idle "images/gui/main_menu_idle.png"
        hover "images/gui/main_menu_hover.png"
        selected_idle "images/gui/main_menu_selected.png"
        selected_hover "images/gui/main_menu_selected.png"

        alpha True

        hotspot(622,325,150,45) action Start()
        hotspot(622,375,150,45) action ShowMenu("load")
        hotspot(622,425,150,45) action ShowMenu("extra")
        hotspot(622,475,150,45) action ShowMenu("options")
        hotspot(622,525,150,45) action Quit(confirm=True)

    on "replace" action Play("music", "bgm/M01.ogg")

Post Reply

Who is online

Users browsing this forum: deltadidirac