Changing screen that a ButtonLeadsToAfterCompletion[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
Avnish
Newbie
Posts: 9
Joined: Tue May 27, 2014 4:25 pm
Completed: Rpercussions
Projects: None, as yet.
Contact:

Changing screen that a ButtonLeadsToAfterCompletion[Solved]

#1 Post by Avnish » Tue May 27, 2014 4:50 pm

Hi.
This problem has been pestering me for quite a while now.
I added a new button to the main menu of my visual novel called "Developer".
By default, or whenever the player reaches a bad ending, if the button is clicked then it changes the background saying "Access Denied" and a single button at the bottom that leads back to the main menu.
But if the player reaches a good ending, the main menu remains the same, but now if the button is clicked it changes the background saying "Congratulations! I hope you enjoyed the game!" and a single button at the bottom to lead back to main menu.
I've been able to get the desired effect only when I set the main menu style to "default".
Is there any way to achieve this when the main menu style is "mm_root"?

I visited the following thread but it only enabled me to change the background of the main menu once the player reaches the good ending.

http://lemmasoft.renai.us/forums/viewto ... =8&t=22612

I'm posting the code of screens.rpy in which I've defined the main menu to be displayed after the good ending. The screens pertaining to the additional button "Developer" are labeled "DAM" (for godd ending) and "DAMN" (for bad ending).

Code: Select all

# Main Menu 
#
# Screen that's used to display the main menu, when Ren'Py first starts
# http://www.renpy.org/doc/html/screen_special.html#main-menu

screen main_menu:

     
    

    # This ensures that any other menu screen is replaced.
    tag menu
    if persistent.ending == "good"
    use 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 _("Developer") action ShowMenu("DAMN")
        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"
   
 

   
########################################################    
    
##Main Menu 1

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

    # 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)
        
        
        textbutton _("Developer") action ShowMenu("DAM")
       
        
       
        
init -2 python:

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



    
    
########################################################
#DAMN
screen DAMN:
    tag menu
    window:
        style "damn"
    
    frame:
        style_group "mm"
        xpos 0.5 xanchor 0.0
        ypos 0.9 yanchor 0.0
        
        textbutton _("Main Menu") action ShowMenu("main_menu")
        
init -2 python:

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

#######################################################
#DAM
screen DAM:
    tag menu
    window:
        style "dam"
    frame:
        style_group "mm"
        xpos 0.5 xanchor 0.0
        ypos 0.9 yanchor 0.0
        
        textbutton _("Main Menu") action ShowMenu("main_menu_1")
        
        
init -2 python:

    # Make all the main menu buttons be the same size.
    style.mm_button.size_group = "mm"                
        
In short, I want to change the menu to main_menu_1 after the player reaches good ending, but as I said earlier, it happens only when main_menu style is "default".
Is there any way to make it work with main_menu style "mm_root".

I'm also posting the code in options.rpy in which I've defined the styles "dam" and "damn".

Code: Select all

init python:
    style.damn=Style(style.default)
    style.damn.background="damn.jpg"
    
init python:
    style.dam=Style(style.default)
    style.dam.background="dam.jpg"
Please help. I've to complete this project in 3 days.
Thank You.
Last edited by Avnish on Sun Jun 08, 2014 4:45 am, edited 1 time in total.

User avatar
Avnish
Newbie
Posts: 9
Joined: Tue May 27, 2014 4:25 pm
Completed: Rpercussions
Projects: None, as yet.
Contact:

Re: Changing screen that a button leads to after completion,

#2 Post by Avnish » Wed May 28, 2014 6:30 am

I solved the problem after a bit of tinkiering.
The new code looks like this:

Code: Select all

##############################################################################
# Main Menu 
#
# Screen that's used to display the main menu, when Ren'Py first starts
# http://www.renpy.org/doc/html/screen_special.html#main-menu

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")
        textbutton _("Developer") action ShowMenu("DAMN")
        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"
   
 

   
########################################################    

#DAMN
screen DAMN:
    tag menu
    
    if persistent.ending=="good":
        window:
            style "dam"
    else:
        window:
            style "damn"
    
     
    frame:
        style_group "mm"
        xpos 0.5 xanchor 0.0
        ypos 0.9 yanchor 0.0
        
        textbutton _("Main Menu") action ShowMenu("main_menu")
        
init -2 python:

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

#######################################################
#DAM
screen DAM:
    tag menu
    window:
        style "dam"
    frame:
        style_group "mm"
        xpos 0.5 xanchor 0.0
        ypos 0.9 yanchor 0.0
        
        textbutton _("Main Menu") action ShowMenu("main_menu")
        
        
init -2 python:

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

    
    


##############################################################################
I removed main_menu_1 and placed the "if persistent.ending=="good":" condition in the DAMN screen instead. So whenever the player clicks the "Developer " button, the control will go to the DAMN screen where it'll check if persistent.ending is good and then display the corresponding background.

Post Reply

Who is online

Users browsing this forum: enaielei