Adding a new button to Main Menu upon Game Completion?

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
Goblin Maiden
Regular
Posts: 28
Joined: Fri Mar 01, 2013 8:25 pm
Completed: Fest-off!
Projects: Yarn Shop Hop
Location: USA
Contact:

Adding a new button to Main Menu upon Game Completion?

#1 Post by Goblin Maiden »

Hi, everyone, I'm trying to add a button to the Main Menu that will lead to an Extras screen where I can share a few tracks, some background info, etc.

The game runs fine, everything is hunky dory. Except for one thing. No Extras button is showing up. I've tried playing through the game, and even then no Extras button appears.

I tried adding a persistent line to the ending, both before and after the credits that run at the end (but before the return code) but it apparently doesn't work. Here's the code I'm using:

In the Script file, this is the last line of the game, the persistent code, and then after that the credits start.

Code: Select all

    'But I\’\m going to try and find it.'
    $ persistent.ending = "Ending 1"    

init:
    ## I put my credits images on this page because I copy-paste this whole file into
    ## all of my games. This way, all I need to change are the images themselves, and
    ## the music I use for the credits. Everything else stays exactly the same.
This is what I have for the main menu and the changed main menu with the Extras text button added:

Code: Select all

screen main_menu:  
    # This ensures that any other menu screen is replaced.
    tag menu          
    
    if persistent.ending == "Ending 1":
        use main_menu_1
    else:
        use main_menu
    
    # The background of the main menu.
    window:
        style "mm_root"

    # The main menu buttons.
    frame:
        style_group "mm"
        xalign .98
        yalign .98

        has vbox

        textbutton _("Start Game") action Start()
        textbutton _("Load Game") action ShowMenu("load")
        textbutton _("Preferences") action ShowMenu("preferences")
        textbutton _("Help") action Help()
        textbutton _("Quit") action Quit(confirm=False)

screen main_menu_1:
    tag menu
    
        # The background of the main menu.
    window:
        style "mm_root"

    # The main menu buttons.
    frame:
        style_group "mm"
        xalign .98
        yalign .98

        has vbox

        textbutton _("Start Game") action Start()
        textbutton _("Load Game") action ShowMenu("load")
        textbutton _("Extras") action ShowMenu("extras")
        textbutton _("Preferences") action ShowMenu("preferences")
        textbutton _("Help") action Help()
        textbutton _("Quit") action Quit(confirm=False)          
        
init -2 python:

    # Make all the main menu buttons be the same size.
    style.mm_button.size_group = "mm"
And here's the code for the Extras screen in question, at least what I have for it so far:

Code: Select all

screen extras:
    
    tag menu

    window:
        style "bg university"

        textbutton _("Track 1. Thinking of You") action "thinking of you.mp3"
        textbutton _("Track 2. Light Thought var 2") action "light thought var 2.mp3"
        textbutton _("Track 3, Eternal Hope") action "eternal hope.mp3"
        textbutton _("Main Menu") action ShowMenu("main_menu")
        textbutton _("Quit") action Quit(confirm=False)  
        
    frame:
        style_group "mm"
        xalign .98
        yalign .98

        has vbox
        
init -2 python:

    # Make all the main menu buttons be the same size.
    style.mm_button.size_group = "mm"
Let me know if any more info's needed. Thanks so much in advance for any help you can give. :)
Writer, coder, audio editor
Currently prepping for Yuri Jam '16!
Fest-off [Hakuoki Fangame][Kenetic][GxB][NaNoReNo 2015]

Juny
Newbie
Posts: 23
Joined: Mon Aug 27, 2012 8:22 am
Contact:

Re: Adding a new button to Main Menu upon Game Completion?

#2 Post by Juny »

Code: Select all

screen main_menu: 
    # This ensures that any other menu screen is replaced.
    tag menu         
   
    # The background of the main menu.
    window:
        style "mm_root"

    # The main menu buttons.
    frame:
        style_group "mm"
        xalign .98
        yalign .98

        has vbox

        textbutton _("Start Game") action Start()
        textbutton _("Load Game") action ShowMenu("load")
        if persistent.ending == "Ending 1":
            textbutton _("Extras") action ShowMenu("extras")
        textbutton _("Preferences") action ShowMenu("preferences")
        textbutton _("Help") action Help()
        textbutton _("Quit") action Quit(confirm=False)
If you define persistent.ending to something else in another ending, the code above won't work anymore: you might want a variable to check if you saw ANY ending (and use it to add the extra), and a different one to track WHICH.

If for whatever reason you need separate screens (untested but the logic is there):

Code: Select all

screen main_menu: 
    # This ensures that any other menu screen is replaced.
    tag menu         
   
    if persistent.ending == "Ending 1":
        use main_menu_1
    else:
        use main_menu_2
   
screen main_menu_2:
    # The background of the main menu.
    window:
        style "mm_root"

    # The main menu buttons.
    frame:
        style_group "mm"
        xalign .98
        yalign .98

        has vbox

        textbutton _("Start Game") action Start()
        textbutton _("Load Game") action ShowMenu("load")
        textbutton _("Preferences") action ShowMenu("preferences")
        textbutton _("Help") action Help()
        textbutton _("Quit") action Quit(confirm=False)

screen main_menu_1:
   
    # The background of the main menu.
    window:
        style "mm_root"

    # The main menu buttons.
    frame:
        style_group "mm"
        xalign .98
        yalign .98

        has vbox

        textbutton _("Start Game") action Start()
        textbutton _("Load Game") action ShowMenu("load")
        textbutton _("Extras") action ShowMenu("extras")
        textbutton _("Preferences") action ShowMenu("preferences")
        textbutton _("Help") action Help()
        textbutton _("Quit") action Quit(confirm=False)         
       
init -2 python:

    # Make all the main menu buttons be the same size.
    style.mm_button.size_group = "mm"

User avatar
Goblin Maiden
Regular
Posts: 28
Joined: Fri Mar 01, 2013 8:25 pm
Completed: Fest-off!
Projects: Yarn Shop Hop
Location: USA
Contact:

Re: Adding a new button to Main Menu upon Game Completion?

#3 Post by Goblin Maiden »

It worked! Thank you so much, Juny!
Writer, coder, audio editor
Currently prepping for Yuri Jam '16!
Fest-off [Hakuoki Fangame][Kenetic][GxB][NaNoReNo 2015]

Post Reply

Who is online

Users browsing this forum: No registered users