Ren'Py stats relationship screen problem

DanStory

Newbie
Sep 30, 2021
50
66
So, i have some problem about screen stats, when i clicked on screen hope if i wanna to go back/see other char progress i have to click return button and click another char to open their stats.
but in here after i clicked image for hope, and the stats show up, when i clicked another place when the other char imagemap i place it, that immediately open the other char stats without i click return button.
the code i used like this.

Python:
screen stats:
    imagemap:
        ground "images/stats/stats_idle.png"
        hover "images/stats/stats_hover.png"

        hotspot (1616,21,282,86) action ShowMenu("relationship")

screen relationship:
    imagemap:
        ground "images/stats/relationship_idle.png"
        hover "images/stats/relationship_hover.png"

        hotspot (1725,975,197,103) action Return()
        hotspot (1538,84,346,878) action ShowMenu("hope")
        hotspot (1209,79,308,917) action ShowMenu("harper")

screen hope:
    imagemap:
        ground "images/stats/background stats hope_idle.png"
        hover "images/stats/background stats hope_hover.png"

        text "Beatrix Affection : " xalign 0.1 yalign 0.90
        text "[Beatrix_affection] " xalign 0.26 yalign 0.90

        text "Hope Affection : " xalign 0.1 yalign 0.80
        text "[Hope_affection] " xalign 0.26 yalign 0.80


        hotspot (1652,956,225,113) action ToggleScreen("hope")

screen harper:
    imagemap:
        ground "images/stats/background stats harper_idle.png"
        hover "images/stats/background stats harper_hover.png"

        text "Liana Affection : " xalign 0.1 yalign 0.90
        text "[Liana_affection] " xalign 0.26 yalign 0.90

        text "Harper Affection : " xalign 0.1 yalign 0.80
        text "[Harper_affection] " xalign 0.26 yalign 0.80

        hotspot (1659,949,220,131) action ToggleScreen("harper")
can someone help to fix this, so after i click char stats i've to click return button to go back first and click another char
thank you for your help..
 

MidnightArrow

Active Member
Aug 22, 2021
500
451
Just use Show() and Hide() instead. Best to keep it simple to avoid getting fucked over by some hidden conditions the manual glosses right over.
 

MidnightArrow

Active Member
Aug 22, 2021
500
451
can you give me the example of the code dude?
im sorry, im completely new in coding
Wherever you see the action parameter, you assign it one of the screen actions to run.



Instead of action ShowMenu("relationship_stats"), use action Show("relationship_stats"). And instead of action ToggleMenu("harper"), use action Hide(). Omitting the argument will hide the screen it's assigned to, which is what you want.
 
  • Like
Reactions: gojira667

DanStory

Newbie
Sep 30, 2021
50
66
Wherever you see the action parameter, you assign it one of the screen actions to run.



Instead of action ShowMenu("relationship_stats"), use action Show("relationship_stats"). And instead of action ToggleMenu("harper"), use action Hide(). Omitting the argument will hide the screen it's assigned to, which is what you want.
Okay thanks dude, i'll try it
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
can someone help to fix this, [...]
It will be long, because there's not much right.

Firstly, is probably not what you should use here.
It change Ren'Py's state, from "in game" to "in main menu". While it's not technically speaking a problem, it's not recommended to use it for in game features ; what your stats menu and relation screens are.

Secondly, is depreciated since years.
You should use instead. It would give you more flexibility.

Thirdly, the text statement should not be inside the imagemap.
While it accept it, what is surprising, imagemap should limits to its effective children. The text statements should be in a regular box block, like vbox, hbox or frame by example.

Fourthly, it's not really convenient, in terms of User Interface design, to have this "click then return" pattern.
You should design your "relationship" screen to include the stats. Then, the player just have to click on the girls icon to see her stats, then on another icon to see the stats for another girl, without having to change screen.

Fifthly, you exit the "relationship" screen, returning to the game flow.
This is really confusing since it initially come from "stats" screen... What is this screen exactly, how is it displayed, and why don't you return to it ?

Sixthly, the () is missing in the screen declaration.
. Without it, the screen will not benefit from some optimizations.


In the end, your code should looks like something near to this:
Python:
init python:

    #  /!\ Assuming, from the code you shown, that "stats" is just here to
    # open the relationship menu. /!\
    #  Add the screen as overlay, for it to always appear on top of the screen
    # content, unless Ren'Py is in "main menu" state.
    config.overlay_screens.append( "stats" )

#  A single button that will open/close the relationship menu anytime the
# player want to see it.
screen stats():

    imagebutton:
        idle  "openRelationshipIcon_idle.png"
        hover "openRelationshipIcon_hover.png"
        #  Used as explicit example, but should be:
        # auto "openRelationshipIcon_%s.png"
        #  The positions are arbitrary, taken directly from you code. They
        # are here purely for the example.
        xpos 1616
        ypos 21
        #  One click open the "relationship" screen, another close it.
        action ToggleScreen( "relationship" )


screen relationship():

    #  Ensure that a click outside of a button will not make the game advance.
    modal True

    #  Store for which character the screen should show informations.
    # By default /None/.
    default characterSelected = None

    #  The icon button for Hope. Clicking on it will display the stats for
    # her, and automatically remove the previously shown stats if there is.
    imagebutton:
        idle  "hopeRelationIcon_idle.png"
        hover "hopeRelationIcon_hover.png"
        # Used as explicit example, but should be
        # auto "hopeRelationIcon_%s.png"
        #  The positions are arbitrary, taken directly from you code. They
        # are here purely for the example.
        xpos 1538
        ypos 84
        #  The player want to see the informations for "hope"
        action SetScreenVariable( "characterSelected", "hope" )

    #  The icon button for Harper. Clicking on it will display the stats for
    # her, and automatically remove the previously shown stats if there is.
    imagebutton:
        idle  "harperRelationIcon_idle.png"
        hover "harperRelationIcon_hover.png"
        # Used as explicit example, but should be
        # auto "harperRelationIcon_%s.png"
        #  The positions are arbitrary, taken directly from you code. They
        # are here purely for the example.
        xpos 1209
        ypos 79
        #  The player want to see the informations for "harper"
        action SetScreenVariable( "characterSelected", "harper" )

    #  There's no need to a return button since the screen is closed
    # from "stats".

    #  Frame where the information are displayed, if there's information
    # to display. It's important to put this in a frame to ensure that the
    # possible background will not overflow.
    frame:
        #  The frame is placed below the buttons for each character.
        ypos 500

        #  If a character is selected...
        if characterSelected:
            # include it's screen in order to show the information.
            # The /expression/ keyword permit to build the name of the screen
            # in real time. Here, it's the value stored into the /characterSelected/
            # variable.
            use expression characterSelected
        #  If there's not character selected...
        else:
            # display a blank screen.
            # It's just an example, you can perfectly not use the /else/ part at
            # all, and let the screen blank.
            add "blank stats.png"


# The screen to include that will show Hope stats.
screen hope():

    #  All children (here /add/ and /grid/) will be positioned starting from
    # the top left corner.
    fixed:

        #  Image to show as background.
        add "stats hope.png"

        #  Two rows of two columns.
        grid 2 2:

            #  Centered in the display zone for the example, but you
            # put it wherever you want it to be.
            xalign 0.5
            yalign 0.5

            #  No need to position them, the grid will do it for you, including
            # the vertical alignment.
            text "Beatrix Affection : "
            text "[Beatrix_affection] "

            text "Hope Affection : "
            text "[Hope_affection] "


#  The screen to include that will show Harper stats.
screen harper():
    fixed:

        add "stats harper.png"

        grid 2 2:
            xalign 0.5
            yalign 0.5

            text "Liana Affection : "
            text "[Liana_affection] "

            text "Harper Affection : "
            text "[Harper_affection] "
Have been used, in addition to what have been linked previously:

The screen property.
The configuration value.
The screen action.
The and screen control statements.
The , , and screen statements.
 
  • Like
Reactions: gojira667

DanStory

Newbie
Sep 30, 2021
50
66
It will be long, because there's not much right.

Firstly, is probably not what you should use here.
It change Ren'Py's state, from "in game" to "in main menu". While it's not technically speaking a problem, it's not recommended to use it for in game features ; what your stats menu and relation screens are.

Secondly, is depreciated since years.
You should use instead. It would give you more flexibility.

Thirdly, the text statement should not be inside the imagemap.
While it accept it, what is surprising, imagemap should limits to its effective children. The text statements should be in a regular box block, like vbox, hbox or frame by example.

Fourthly, it's not really convenient, in terms of User Interface design, to have this "click then return" pattern.
You should design your "relationship" screen to include the stats. Then, the player just have to click on the girls icon to see her stats, then on another icon to see the stats for another girl, without having to change screen.

Fifthly, you exit the "relationship" screen, returning to the game flow.
This is really confusing since it initially come from "stats" screen... What is this screen exactly, how is it displayed, and why don't you return to it ?

Sixthly, the () is missing in the screen declaration.
. Without it, the screen will not benefit from some optimizations.


In the end, your code should looks like something near to this:
Python:
init python:

    #  /!\ Assuming, from the code you shown, that "stats" is just here to
    # open the relationship menu. /!\
    #  Add the screen as overlay, for it to always appear on top of the screen
    # content, unless Ren'Py is in "main menu" state.
    config.overlay_screens.append( "stats" )

#  A single button that will open/close the relationship menu anytime the
# player want to see it.
screen stats():

    imagebutton:
        idle  "openRelationshipIcon_idle.png"
        hover "openRelationshipIcon_hover.png"
        #  Used as explicit example, but should be:
        # auto "openRelationshipIcon_%s.png"
        #  The positions are arbitrary, taken directly from you code. They
        # are here purely for the example.
        xpos 1616
        ypos 21
        #  One click open the "relationship" screen, another close it.
        action ToggleScreen( "relationship" )


screen relationship():

    #  Ensure that a click outside of a button will not make the game advance.
    modal True

    #  Store for which character the screen should show informations.
    # By default /None/.
    default characterSelected = None

    #  The icon button for Hope. Clicking on it will display the stats for
    # her, and automatically remove the previously shown stats if there is.
    imagebutton:
        idle  "hopeRelationIcon_idle.png"
        hover "hopeRelationIcon_hover.png"
        # Used as explicit example, but should be
        # auto "hopeRelationIcon_%s.png"
        #  The positions are arbitrary, taken directly from you code. They
        # are here purely for the example.
        xpos 1538
        ypos 84
        #  The player want to see the informations for "hope"
        action SetScreenVariable( "characterSelected", "hope" )

    #  The icon button for Harper. Clicking on it will display the stats for
    # her, and automatically remove the previously shown stats if there is.
    imagebutton:
        idle  "harperRelationIcon_idle.png"
        hover "harperRelationIcon_hover.png"
        # Used as explicit example, but should be
        # auto "harperRelationIcon_%s.png"
        #  The positions are arbitrary, taken directly from you code. They
        # are here purely for the example.
        xpos 1209
        ypos 79
        #  The player want to see the informations for "harper"
        action SetScreenVariable( "characterSelected", "harper" )

    #  There's no need to a return button since the screen is closed
    # from "stats".

    #  Frame where the information are displayed, if there's information
    # to display. It's important to put this in a frame to ensure that the
    # possible background will not overflow.
    frame:
        #  The frame is placed below the buttons for each character.
        ypos 500

        #  If a character is selected...
        if characterSelected:
            # include it's screen in order to show the information.
            # The /expression/ keyword permit to build the name of the screen
            # in real time. Here, it's the value stored into the /characterSelected/
            # variable.
            use expression characterSelected
        #  If there's not character selected...
        else:
            # display a blank screen.
            # It's just an example, you can perfectly not use the /else/ part at
            # all, and let the screen blank.
            add "blank stats.png"


# The screen to include that will show Hope stats.
screen hope():

    #  All children (here /add/ and /grid/) will be positioned starting from
    # the top left corner.
    fixed:

        #  Image to show as background.
        add "stats hope.png"

        #  Two rows of two columns.
        grid 2 2:

            #  Centered in the display zone for the example, but you
            # put it wherever you want it to be.
            xalign 0.5
            yalign 0.5

            #  No need to position them, the grid will do it for you, including
            # the vertical alignment.
            text "Beatrix Affection : "
            text "[Beatrix_affection] "

            text "Hope Affection : "
            text "[Hope_affection] "


#  The screen to include that will show Harper stats.
screen harper():
    fixed:

        add "stats harper.png"

        grid 2 2:
            xalign 0.5
            yalign 0.5

            text "Liana Affection : "
            text "[Liana_affection] "

            text "Harper Affection : "
            text "[Harper_affection] "
Have been used, in addition to what have been linked previously:

The screen property.
The configuration value.
The screen action.
The and screen control statements.
The , , and screen statements.
I'm using this and it's work..
what do you think?
I'll add the unfinished image maybe it will make it easier for you to understand what i mean..

Python:
screen stats:
    imagemap:
        ground "images/stats/stats_idle.png"
        hover "images/stats/stats_hover.png"

        hotspot (1616,21,282,86) action ShowMenu("relationship")

screen relationship:
    imagemap:
        ground "images/stats/relationship_idle.png"
        hover "images/stats/relationship_hover.png"

        hotspot (1725,975,197,103) action Return()
        hotspot (1538,84,346,878) action ShowMenu("hope"), Hide("relationship")
        hotspot (1209,79,308,917) action ShowMenu("harper"), Hide("relationship")

screen hope:
    imagemap:
        ground "images/stats/background stats hope_idle.png"
        hover "images/stats/background stats hope_hover.png"

        text "Beatrix Affection : " xalign 0.1 yalign 0.90
        text "[Beatrix_affection] " xalign 0.26 yalign 0.90

        text "Hope Affection : " xalign 0.1 yalign 0.80
        text "[Hope_affection] " xalign 0.26 yalign 0.80

        hotspot (1652,956,225,113) action Hide("hope"), ShowMenu("relationship")

screen harper:
    imagemap:
        ground "images/stats/background stats harper_idle.png"
        hover "images/stats/background stats harper_hover.png"

        text "Liana Affection : " xalign 0.1 yalign 0.90
        text "[Liana_affection] " xalign 0.26 yalign 0.90

        text "Harper Affection : " xalign 0.1 yalign 0.80
        text "[Harper_affection] " xalign 0.26 yalign 0.80

        hotspot (1659,949,220,131) action Hide("harper"), ShowMenu("relationship")
i just wanna to show the stats when ppl who play wanna check their relationship stats
thanks for the code dude i'll save it and try it