[Solved] Main Menu Changes to Last Variation Made

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
JaredKHAce
Newbie
Posts: 20
Joined: Thu Oct 25, 2018 2:35 pm
Contact:

[Solved] Main Menu Changes to Last Variation Made

#1 Post by JaredKHAce » Fri May 07, 2021 2:49 am

I will admit that when it comes to coding in Ren'py, stuff beyond the basics is still new to me, but this has had me confused for a little while now. I am implementing different variations of my game's title screen depending on the endings you have achieved. It accumulates, so I account for all combinations. The problem is that, in order to test this feature from the beginning, I had to use the delete persistent in order to reset the parameters. Everything else tied to a persistent variable works fine still, but my screens.rpy part of the code has stopped working right for whatever reason. Here is the code at length, the tldr is just below it.

Code: Select all

screen main_menu:
    if persistent.Tau_GoodEnd == True and persistent.Ru_GoodEnd == False and persistent.Jen_GoodEnd == False:
        use main_menu_1t
    elif persistent.Tau_GoodEnd == False and persistent.Ru_GoodEnd == False and persistent.Jen_GoodEnd == True:
        use main_menu_1j
    elif persistent.Tau_GoodEnd == False and persistent.Ru_GoodEnd == True and persistent.Jen_GoodEnd == False:
        use main_menu_1r
    else:
        use main_menu_0

#Main Menu change after ending
screen main_menu_0():

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

    imagemap:
        ground "main_menu.png"

    style_prefix "main_menu"

    add gui.main_menu_background

    ## This empty frame darkens the main menu.
    frame:
        pass

    ## The use statement includes another screen inside this one. The actual
    ## contents of the main menu are in the navigation screen.
    textbutton _("{size=45}START GAME{/size}") action Start() yalign 0.45 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ] activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"
    textbutton _("{size=45}LOAD GAME{/size}") action ShowMenu("load") yalign 0.55 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ]  activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"
    textbutton _("{size=45}SETTINGS{/size}") action ShowMenu("preferences") yalign 0.65 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ] activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"
    textbutton _("{size=45}QUIT GAME{/size}") action Quit(confirm=not main_menu) yalign 0.75 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ] activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"

    if gui.show_name:

        vbox:
            text "[config.name!t]":
                style "main_menu_title"

            text "[config.version]":
                style "main_menu_version"

transform logoin:

style main_menu_frame is empty
style main_menu_vbox is vbox
style main_menu_text is gui_text
style main_menu_title is main_menu_text
style main_menu_version is main_menu_text

style main_menu_frame:
    xsize 420
    yfill True

    background "gui/overlay/main_menu.png"

style main_menu_vbox:
    xalign 1.0
    xoffset -30
    xmaximum 1200
    yalign 1.0
    yoffset -30

style main_menu_text:
    properties gui.text_properties("main_menu", accent=True)

style main_menu_title:
    properties gui.text_properties("title")

style main_menu_version:
    properties gui.text_properties("version")

screen main_menu_1t():

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

    imagemap:
        ground "main_menu.png"

    style_prefix "main_menu"

    add gui.main_menu_background

    ## This empty frame darkens the main menu.
    frame:
        pass

    ## The use statement includes another screen inside this one. The actual
    ## contents of the main menu are in the navigation screen.
    textbutton _("{size=45}START GAME{/size}") action Start() yalign 0.45 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ] activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"
    textbutton _("{size=45}LOAD GAME{/size}") action ShowMenu("load") yalign 0.55 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ]  activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"
    textbutton _("{size=45}SETTINGS{/size}") action ShowMenu("preferences") yalign 0.65 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ] activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"
    textbutton _("{size=45}QUIT GAME{/size}") action Quit(confirm=not main_menu) yalign 0.75 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ] activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"

    if gui.show_name:

        vbox:
            text "[config.name!t]":
                style "main_menu_title"

            text "[config.version]":
                style "main_menu_version"

transform logoin:

style main_menu_frame is empty
style main_menu_vbox is vbox
style main_menu_text is gui_text
style main_menu_title is main_menu_text
style main_menu_version is main_menu_text

style main_menu_frame:
    xsize 420
    yfill True

    background "gui/overlay/main_menu_tau.png"

style main_menu_vbox:
    xalign 1.0
    xoffset -30
    xmaximum 1200
    yalign 1.0
    yoffset -30

style main_menu_text:
    properties gui.text_properties("main_menu", accent=True)

style main_menu_title:
    properties gui.text_properties("title")

style main_menu_version:
    properties gui.text_properties("version")

#Jen Good End Only
screen main_menu_1j():

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

    imagemap:
        ground "main_menu.png"

    style_prefix "main_menu"

    add gui.main_menu_background

    ## This empty frame darkens the main menu.
    frame:
        pass

    ## The use statement includes another screen inside this one. The actual
    ## contents of the main menu are in the navigation screen.
    textbutton _("{size=45}START GAME{/size}") action Start() yalign 0.45 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ] activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"
    textbutton _("{size=45}LOAD GAME{/size}") action ShowMenu("load") yalign 0.55 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ]  activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"
    textbutton _("{size=45}SETTINGS{/size}") action ShowMenu("preferences") yalign 0.65 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ] activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"
    textbutton _("{size=45}QUIT GAME{/size}") action Quit(confirm=not main_menu) yalign 0.75 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ] activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"

    if gui.show_name:

        vbox:
            text "[config.name!t]":
                style "main_menu_title"

            text "[config.version]":
                style "main_menu_version"

transform logoin:

style main_menu_frame is empty
style main_menu_vbox is vbox
style main_menu_text is gui_text
style main_menu_title is main_menu_text
style main_menu_version is main_menu_text

style main_menu_frame:
    xsize 420
    yfill True

    background "gui/overlay/main_menu_jen.png"

style main_menu_vbox:
    xalign 1.0
    xoffset -30
    xmaximum 1200
    yalign 1.0
    yoffset -30

style main_menu_text:
    properties gui.text_properties("main_menu", accent=True)

style main_menu_title:
    properties gui.text_properties("title")

style main_menu_version:
    properties gui.text_properties("version")

#Ru Good End Only
screen main_menu_1r():

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

    imagemap:
        ground "main_menu.png"

    style_prefix "main_menu"

    add gui.main_menu_background

    ## This empty frame darkens the main menu.
    frame:
        pass

    ## The use statement includes another screen inside this one. The actual
    ## contents of the main menu are in the navigation screen.
    textbutton _("{size=45}START GAME{/size}") action Start() yalign 0.45 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ] activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"
    textbutton _("{size=45}LOAD GAME{/size}") action ShowMenu("load") yalign 0.55 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ]  activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"
    textbutton _("{size=45}SETTINGS{/size}") action ShowMenu("preferences") yalign 0.65 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ] activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"
    textbutton _("{size=45}QUIT GAME{/size}") action Quit(confirm=not main_menu) yalign 0.75 xalign 0.05 text_outlines [ (2, "#202020", absolute (1), 1) ] activate_sound "bellclick.mp3" hover_sound "bellhover.mp3"

    if gui.show_name:

        vbox:
            text "[config.name!t]":
                style "main_menu_title"

            text "[config.version]":
                style "main_menu_version"

transform logoin:

style main_menu_frame is empty
style main_menu_vbox is vbox
style main_menu_text is gui_text
style main_menu_title is main_menu_text
style main_menu_version is main_menu_text

style main_menu_frame:
    xsize 420
    yfill True

    background "gui/overlay/main_menu_Ru.png"

style main_menu_vbox:
    xalign 1.0
    xoffset -30
    xmaximum 1200
    yalign 1.0
    yoffset -30

style main_menu_text:
    properties gui.text_properties("main_menu", accent=True)

style main_menu_title:
    properties gui.text_properties("title")

style main_menu_version:
    properties gui.text_properties("version")
What I want to happen is the title screen to change based on the parameters met, but what ends up happening is that the title screen will only ever show the main menu variation that is written last regardless of the parameters that have been met. I tried this with another version of the program and the exact same issue happened after deleting the persistent variables. What am I doing wrong? Any help would be greatly appreciated. Thank you very much.
Last edited by JaredKHAce on Fri May 07, 2021 2:27 pm, edited 1 time in total.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1077
Joined: Tue Aug 23, 2016 10:35 am
Skype: miinipaa
Contact:

Re: Main Menu Changes to Last Variation Made

#2 Post by Ocelot » Fri May 07, 2021 3:33 am

After resetting persistent. persistent.Ru_GoodEnd == False will yield False, because actual value of persistent.Ru_GoodEnd is None. If it is not what you want, I suggest to stop using tautological comparisons to boolean values and write your condition like that: if persistent.Tau_GoodEnd and not persistent.Ru_GoodEnd and not persistent.Jen_GoodEnd:. Another thing to keep in mind: if two or more good end variables are set, you will default to main_menu_0.
< < insert Rick Cook quote here > >

JaredKHAce
Newbie
Posts: 20
Joined: Thu Oct 25, 2018 2:35 pm
Contact:

Re: Main Menu Changes to Last Variation Made

#3 Post by JaredKHAce » Fri May 07, 2021 10:48 am

Ocelot wrote:
Fri May 07, 2021 3:33 am
After resetting persistent. persistent.Ru_GoodEnd == False will yield False, because actual value of persistent.Ru_GoodEnd is None. If it is not what you want, I suggest to stop using tautological comparisons to boolean values and write your condition like that: if persistent.Tau_GoodEnd and not persistent.Ru_GoodEnd and not persistent.Jen_GoodEnd:. Another thing to keep in mind: if two or more good end variables are set, you will default to main_menu_0.
I hope you don't mind if I ask for some more clarification on this. The problem, at least from what I can tell, is not that the persistent values are set to None, since that is intended to test out the main menu change. What has me confused is that, no matter what, the screen version implemented at the bottom of the code becomes the default. Not only that, when achieving a different good ending the title screen does not change to a different version.

And yeah, I figured the title screen would default to main_menu_0 in this situation. I do have the rest of the code written down for the combinations, but I just wanted to test the first basic three before moving on to the rest.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1077
Joined: Tue Aug 23, 2016 10:35 am
Skype: miinipaa
Contact:

Re: Main Menu Changes to Last Variation Made

#4 Post by Ocelot » Fri May 07, 2021 10:55 am

If you clear all variables, then set persistent.Tau_GoodEnd to True then following condition will not work:

Code: Select all

if persistent.Tau_GoodEnd == True and persistent.Ru_GoodEnd == False and persistent.Jen_GoodEnd == False:
and it will show the default screen, not main_menu_1t.

You will have to set persistent.Ru_GoodEnd and persistent.Jen_GoodEnd to False manually to make it work. Of just rewrite code without comparisons to booleans, since it is tautological and unnessesary.
< < insert Rick Cook quote here > >

JaredKHAce
Newbie
Posts: 20
Joined: Thu Oct 25, 2018 2:35 pm
Contact:

Re: Main Menu Changes to Last Variation Made

#5 Post by JaredKHAce » Fri May 07, 2021 11:02 am

Alright, I think I understand that. For example, I have the following set in the first script.rpy before the game starts.


#Requirements for True Ending
default persistent.Tau_GoodEnd = False
default persistent.Ru_GoodEnd = False
default persistent.Jen_GoodEnd = False


Does that not meet the condition of being set to False manually? And I am not sure if I made it clear before, but it's not that I am only yielding the default title screen, because that would be fine in this situation. Instead, I am yielding the further title screen down. In this case, main_menu_1r. I will definitely work to remove the booleans, but is if fine if I asked what the default variables above should look like to compensate? Thank you for all the help so far.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1077
Joined: Tue Aug 23, 2016 10:35 am
Skype: miinipaa
Contact:

Re: Main Menu Changes to Last Variation Made

#6 Post by Ocelot » Fri May 07, 2021 11:08 am

Yes, it should work.

Comparison to booleans is a pet peeve of mine, because conditions are implicitely do such comparison internally, so comparing something to True just to compare result to True again afterwards... if(something == True) is a complete equivalent of if (something)
< < insert Rick Cook quote here > >

JaredKHAce
Newbie
Posts: 20
Joined: Thu Oct 25, 2018 2:35 pm
Contact:

Re: Main Menu Changes to Last Variation Made

#7 Post by JaredKHAce » Fri May 07, 2021 1:03 pm

Ah, I see. I'll definitely work towards implementing that in the future. I did change up the syntax, and I believe it is correct:


screen main_menu:
if persistent.Tau_GoodEnd and not persistent.Ru_GoodEnd and not persistent.Jen_GoodEnd:
use main_menu_1t
elif not persistent.Tau_GoodEnd and not persistent.Ru_GoodEnd and persistent.Jen_GoodEnd:
use main_menu_1j
elif not persistent.Tau_GoodEnd and persistent.Ru_GoodEnd and not persistent.Jen_GoodEnd:
use main_menu_1r
else:
use main_menu_0


However, even with this in mind, it still shows "main_menu_1r" instead of "main_menu_0". Changing around the order of what screens variation is last in the list, the game always seems to overwrite the title screen versions above the lowest possible one. Since "main_menu_1r" is currently at the bottom, it shows up on the title screen, but if I switched the places of "main_menu_1t" and "main_menu_1r" from their definitions in screens.rpy, "main_menu_1t" would then show up on the title screen. Do you have any idea why this is happening, Ocelot?

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1077
Joined: Tue Aug 23, 2016 10:35 am
Skype: miinipaa
Contact:

Re: Main Menu Changes to Last Variation Made

#8 Post by Ocelot » Fri May 07, 2021 1:17 pm

I have a question, how you determine which screen is showing, because I didn't spot any differences?

It is not important though. Can yu enter your main menu, press Shift+D, select Variable Viewer and see what actual values those persistent variables have? If the are not showing, in previous menu select Console and enter names of each variable ( persistent.Tau_GoodEnd , etc.) pressing enter after each, it will print their current values.

And the last one: did you delete or rename any rpy file recently?
< < insert Rick Cook quote here > >

JaredKHAce
Newbie
Posts: 20
Joined: Thu Oct 25, 2018 2:35 pm
Contact:

Re: Main Menu Changes to Last Variation Made

#9 Post by JaredKHAce » Fri May 07, 2021 1:29 pm

The I determine which screen is showing by the series of if, elif, and else statements above. There should not be any differences since I just copy-pasted a version of "main_menu_0" and made the appropriate changes for each one.


screen main_menu:
if persistent.Tau_GoodEnd and not persistent.Ru_GoodEnd and not persistent.Jen_GoodEnd:
use main_menu_1t
elif not persistent.Tau_GoodEnd and not persistent.Ru_GoodEnd and persistent.Jen_GoodEnd:
use main_menu_1j
elif not persistent.Tau_GoodEnd and persistent.Ru_GoodEnd and not persistent.Jen_GoodEnd:
use main_menu_1r
else:
use main_menu_0


I tried following the format laid out from this page on the Ren'Py wiki: https://renpy.org/wiki/renpy/doc/cookbo ... g_the_game

I went to Variable Viewer and the only values there are "current_music_vol," "current_sfx_vol," "quick_menu," "show_quick_menu," and "suppress_overlay."

Since the persistent variables were not there I went to Console like you suggested. The current values for persistent.Tau_GoodEnd, persistent.Jen_GoodEnd, and persistent.Ru_GoodEnd are all set to false. The same applies for other variables such as persistent.true_end_game and persistent.Prologue_seen.

Finally, no rpy files have been deleted or renamed since before this glitch occurred. I believe that is everything

It's really strange because the [character]_GoodEnd variables do work. They're each tied to something else that does actually activate when their ending is reached. It's just this specific aspect with the title screen.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1077
Joined: Tue Aug 23, 2016 10:35 am
Skype: miinipaa
Contact:

Re: Main Menu Changes to Last Variation Made

#10 Post by Ocelot » Fri May 07, 2021 1:48 pm

The question was "How do you figure out that it shows wrong screen since they all the same"?

I found the problem, it wasn't in conditions or screens. In fact, correct screen was showing all the time.
It was in styles. You are overwriting main_menu_frame multiple times. And only last change sticks. The solution either to use different styles for different menus, or set background in menu directly.
< < insert Rick Cook quote here > >

JaredKHAce
Newbie
Posts: 20
Joined: Thu Oct 25, 2018 2:35 pm
Contact:

Re: Main Menu Changes to Last Variation Made

#11 Post by JaredKHAce » Fri May 07, 2021 1:53 pm

I can only facepalm at myself. Thank you! Now I am wondering how I can put this into practice. Would it be something like:


#main_menu_0
style main_menu_frame:
xsize 420
yfill True

background "gui/overlay/main_menu.png"



#main_menu_1t
style main_menu_1t_frame:
xsize 420
yfill True

background "gui/overlay/main_menu_tau.png"


And continue to do that for each subsequent variation? Or would I set it here?

screen main_menu:
if persistent.Tau_GoodEnd and not persistent.Ru_GoodEnd and not persistent.Jen_GoodEnd:
use main_menu_1t
elif not persistent.Tau_GoodEnd and not persistent.Ru_GoodEnd and persistent.Jen_GoodEnd:
use main_menu_1j
elif not persistent.Tau_GoodEnd and persistent.Ru_GoodEnd and not persistent.Jen_GoodEnd:
use main_menu_1r
else:
use main_menu_0


If so, how would I do that? Truly though, thank you for all the help. I greatly appreciate it.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1077
Joined: Tue Aug 23, 2016 10:35 am
Skype: miinipaa
Contact:

Re: Main Menu Changes to Last Variation Made

#12 Post by Ocelot » Fri May 07, 2021 1:58 pm

Either you can change style directly, but, if it the only (on one of few) difference in styles, I would keep the style (single copy) and just do:

Code: Select all

screen main_menu_0():
    # ...
    frame:
    	background "some_image"
< < insert Rick Cook quote here > >

JaredKHAce
Newbie
Posts: 20
Joined: Thu Oct 25, 2018 2:35 pm
Contact:

Re: Main Menu Changes to Last Variation Made

#13 Post by JaredKHAce » Fri May 07, 2021 2:24 pm

Yes! That 100% works! It is back to default now when everything is set to false. And trying out getting Tau and Ru's individual good endings work both individually and combined. Thank you so much, Ocelot! You're the best!

Post Reply

Who is online

Users browsing this forum: Google [Bot], illegalileo