Change main menu screen after each route

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
ezyn
Newbie
Posts: 3
Joined: Sat Jan 20, 2018 5:10 pm
Deviantart: ezyn
Contact:

Change main menu screen after each route

#1 Post by ezyn »

I apologize if this has been done already but I tried for many hours looking into persistent data and background change to get what I want but it's not working.
I want to change the main menu background every time the player completes a different route.

Here's what I did:

In script.rpy before the game starts, I defined the persistent to false:

Code: Select all

define persistent.end1 = False
define persistent.end2 = False
define persistent.end3 = False
At the end of each route I made the statement true:

Code: Select all

$ persistent.end1=True
Here's the part I'm not sure if I'm doing right.
The main menu background is changed in options.rpy under the Themes category. So I made a list of the different bgs I will change to. I'm not sure if we're allowed to have more than one mm and that's why it's not reading it? Sorry I'm very new to coding. I feel like I'm doing it in a very roundabout way but I didn't want to risk using more conditions to confuse me.

Code: Select all

## The background of the main menu. This can be a color
        ## beginning with '#', or an image filename. The latter
        ## should take up the full height and width of the screen.
        mm_root = "mm_1.png", #no ending complete, main menu starts with this
        mm_root1 = "mm_2.png", #A ending complete
        mm_root2 = "mm_3.png", #E ending complete 
        mm_root3 = "mm_4.png", #H ending complete
        mm_root4 = "mm_5.png", #A and E ending complete
        mm_root5 = "mm_6.png", #A and H ending complete
        mm_root6 = "mm_7.png", #E and H ending complete
        mm_root7 = "mm_8.png", #A and E and H ending complete
Now in the screens.rpy I made an if condition under the Main Menu category:

Code: Select all

screen main_menu:

    # This ensures that any other menu screen is replaced.
    tag menu

        if persistent.end1: #A
            use main_menu_1
        elif persistent.end2: #E
            use main_menu_2
        elif persistent.end3: #H
            use main_menu_3
        elif persistent.end1 and persistent.end2: #A and E
            use main_menu_4
        elif persistent.end1 and persistent.end3: #A and H
            use main_menu_5
        elif persistent.end2 and persistent.end3: #E and H
            use main_menu_6
        elif persistent.end1 and persistent.end2 and persistent.end3: #A and E and H
            use main_menu_7
        else:
            use main_menu #No route complete
    
    # The background of the main menu.
    window:
        style "mm_root"
After which I made 7 more main menu screens that change the mm_root to the corresponding image I want changed:

Code: Select all

screen main_menu_1:
    tag menu
    window:
        style "mm_root1"
The game runs fine with no errors. I've tried to erase the persistent data before running through a whole route to see if the main menu changes but it doesn't. I feel like the problem is the use of the mm_root but I can't find any tutorials or discussions on this particular topic, please help I would greatly appreciate it.

User avatar
Empish
Veteran
Posts: 221
Joined: Thu Jan 14, 2016 9:52 pm
Projects: Efemural Hearts, It Ends With Graduation
itch: empish
Contact:

Re: Change main menu screen after each route

#2 Post by Empish »

It looks like you're using the legacy GUI. You might want to consider updating. In addition, you're not using the screen language quite right. It looks like whatever menu you might be using, you're overriding it with the main menu window, with this part here:

Code: Select all

window:
   style "mm_root"
How about instead creating a screen variable menu_bg that will be set to the correct background image depending on the persistent data? Then you could do the following:

Code: Select all

window:
    style "mm_root"
    background Frame(menu_bg, 0, 0)

ezyn
Newbie
Posts: 3
Joined: Sat Jan 20, 2018 5:10 pm
Deviantart: ezyn
Contact:

Re: Change main menu screen after each route

#3 Post by ezyn »

How do I do that? I'm sorry I'm not very familiar with coding structure.

Post Reply

Who is online

Users browsing this forum: No registered users