Multiple Title Screens

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
BitticusRex
Newbie
Posts: 13
Joined: Wed Apr 20, 2016 8:00 pm
Contact:

Multiple Title Screens

#1 Post by BitticusRex » Wed Jul 13, 2016 6:52 pm

Hello everyone!

I'm having some difficulty with changing the title screen for my VN. Here is the goal:

The player will see the "main_menu_default" screen the first time they start the program, since persistent.title wouldn't have a value. Once the player clears the prologue, their decisions will determine which character they are going to be playing as. I want to change the title screen based on which character they get. I added the following code to the ends of each route:

Code: Select all

init -2:
     $ persistent.title = "Tristan Title"
and

Code: Select all

init -2:
     $ persistent.title = "Cooper Title"
and here is the code in my "screens.rpy"

Code: Select all

screen main_menu:
    tag menu
    
    if persistent.title == "Tristan Title":
        use main_menu_tristan
    elif persistent.title == "Cooper Title":
        use main_menu_cooper
    else:
        use main_menu_default
        
screen main_menu_default:
    tag menu

    imagemap:
        ground "title.png"
        hover "titlehover.png"

        hotspot (386, 147, 195, 74) action Start()
        hotspot (581, 147, 170, 75) action ShowMenu("load")
        hotspot (751, 146, 157, 78) action ShowMenu("preferences")
        hotspot (0,678,46,40) action OpenURL("https://www.patreon.com/aego?ty=h")
        hotspot (1238,679,37,36)  action OpenURL("https://twitter.com/projectaego")
        
        alpha False
        
screen main_menu_tristan:
    tag menu
    
    imagemap:
        ground "tristantitle.png"
        hover "tristantitlehover.png"
        
        hotspot (1089, 429, 144, 27) action Start()
        hotspot (1089, 458, 143, 31) action ShowMenu("load")
        hotspot (1131, 493, 101, 27) action ShowMenu("preferences")
        hotspot (1147, 522, 85, 27) action ShowMenu()
        hotspot (1143, 555, 91, 27) action ShowMenu()
            
        alpha False
        
screen main_menu_cooper:
    tag menu

    imagemap:
        ground "coopertitle.png"
        hover "coopertitlehover.png"
        
        hotspot (40, 427, 163, 32) action Start()
        hotspot (39, 458, 160, 36) action ShowMenu("load")
        hotspot (45, 494, 117, 31) action ShowMenu("preferences")
        hotspot (44, 527, 103, 30) action ShowMenu()
        hotspot (44, 559, 97, 29) action ShowMenu()
        
        alpha False
So here's the weird thing, even after deleting the persistent data and starting the game fresh, it wants to show the "Tristan" main menu right off the bat, and it doesn't seem to make a difference which character I end up getting, and after I clear the game, it returns to the "Tristan" title screen. (It also doesn't have any music this time.)

I'm pretty stumped on this one. My programming knowledge is pretty limited, but I followed the directions on here: https://www.renpy.org/wiki/renpy/doc/co ... g_the_game

Thanks in advance for your help here, it is much appreciated!

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: Multiple Title Screens

#2 Post by chocoberrie » Wed Jul 13, 2016 7:10 pm

I've never tried this before, but my first thought is that you numbered the init blocks with the same number...? You used init-2 for both menus. Try using init-2 for Tristan's menu and init-3 for Cooper's menu! :)

User avatar
BitticusRex
Newbie
Posts: 13
Joined: Wed Apr 20, 2016 8:00 pm
Contact:

Re: Multiple Title Screens

#3 Post by BitticusRex » Wed Jul 13, 2016 7:19 pm

chocoberrie wrote:I've never tried this before, but my first thought is that you numbered the init blocks with the same number...? You used init-2 for both menus. Try using init-2 for Tristan's menu and init-3 for Cooper's menu! :)

Ok, so I tried this, and now it switched to Cooper's menu, but it only shows his now, even if I clear the game with the path that should change the persistent.title to "Tristan Title" (and thus launch Tristan's title screen going forward). Also, even clearing the persistent data and launching still shows Cooper's screen now, when I want it to show the "Default" screen.

I think I'm not getting something right with the init function. Should I even have the function there if what I want is for the persistent.title variable to change when that specific point is reached?

User avatar
BitticusRex
Newbie
Posts: 13
Joined: Wed Apr 20, 2016 8:00 pm
Contact:

Re: Multiple Title Screens

#4 Post by BitticusRex » Wed Jul 13, 2016 7:42 pm

A little update on this. I managed to get it to work correctly!

One thing I'm curious about. Is it possible, upon loading a file, to check a variable in that save file, and then load persistent data based on that variable? For instance, I want the title screen to change based on which file was loaded last. If the player loads a file where they played as Cooper, then overwrite persistent.title to "Cooper Title" or if they load a file where they are playing as Tristan to overwrite persistent.title to "Tristan Title"?

Post Reply

Who is online

Users browsing this forum: _ticlock_