• To improve security, we will soon start forcing password resets for any account that uses a weak password on the next login. If you have a weak password or a defunct email, please update it now to prevent future disruption.

Ren'Py Need help to hide text.

DanStory

Newbie
Sep 30, 2021
50
66
So, i wanna to hide this:
Python:
text "{size=+30}{font=HeyMarch-MV0Or.ttf}Age{/font}{/size} : " xalign 0.04 yalign 0.30
text "{size=+30}{font=HeyMarch-MV0Or.ttf}21{/font}{/size} " xalign 0.11 yalign 0.30
And show it when you've met the condition, but i'm confused how to do it.
its like, MC have to ask her age first or get information from other so her age stats will shown.
anyone can help me?
thanks
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,193
14,923
And show it when you've met the condition, but i'm confused how to do it.
Well, you just condition it to the condition you want ?

Python:
default MC_know_age = False

screen whatever():
    if MC_know_age:
        text "{size=+30}{font=HeyMarch-MV0Or.ttf}Age{/font}{/size} : " xalign 0.04 yalign 0.30
        text "{size=+30}{font=HeyMarch-MV0Or.ttf}21{/font}{/size} " xalign 0.11 yalign 0.30

label whatever:
    ANNE_O "Hello beauty, how are you ?"
    A_GIRL_NAMED_Jxxxx "I'm as old of your children, you perv' !"
    $ MC_know_age = True

Any resemblance to reality is purely coincidental... or not.
 

DanStory

Newbie
Sep 30, 2021
50
66
Well, you just condition it to the condition you want ?
i want to add stats like age, heigh, hobby, etc in all character screen stats so you will know personal information of all char.

Python:
default MC_know_age = False

screen whatever():
if MC_know_age:
text "{size=+30}{font=HeyMarch-MV0Or.ttf}Age{/font}{/size} : " xalign 0.04 yalign 0.30
text "{size=+30}{font=HeyMarch-MV0Or.ttf}21{/font}{/size} " xalign 0.11 yalign 0.30

label whatever:
ANNE_O "Hello beauty, how are you ?"
A_GIRL_NAMED_Jxxxx "I'm as old of your children, you perv' !"
$ MC_know_age = True
and if i may ask, how to make this stats information still shown even i already finished/complete the game so i can choose different path in the game to unlock the other?
thank you for replying
 

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,149
3,500
and if i may ask, how to make this stats information still shown even i already finished/complete the game so i can choose different path in the game to unlock the other?
thank you for replying
it's the same as the way that AnneO showed you, but you use "persistent" variable which is common to the whole game installation, not just one save file.

Search for "Renpy Persistent Data" and you can find the relevant documentation page.
 

DanStory

Newbie
Sep 30, 2021
50
66
it's the same as the way that AnneO showed you, but you use "persistent" variable which is common to the whole game installation, not just one save file.

Search for "Renpy Persistent Data" and you can find the relevant documentation page.
alright thanks dude i'll try it
 

Turning Tricks

Rendering Fantasies
Game Developer
Apr 9, 2022
843
1,835
alright thanks dude i'll try it
Honestly, what you asked will lead you on a journey down the rabbit hole, learning Ren'py screen actions and functions. I enjoy learning more and more, every day.

There's a ton of examples for different Stat Pages out there and some are simple and many are very complex for the novice programmer like myself. Those that use lists, arrays, etc. Here's an example of a very simple STAT function that you should be able to play with very easily and start learning how to expand it...

Python:
screen StatInfo():

    vbox:
        xalign 0.04
        yalign 0
        textbutton "STATS" action ToggleScreen( "StatDetails" )

screen StatDetails():
    style_prefix "StatStyle"

    if persistent.know_age:
        text "Age: 21"
    else:
        text "Age: Unknown"

style StatStyle_text:
    size 30
    font "HeyMarch-MV0Or.ttf"
    color "#ffff00"
    xalign 0.04
    yalign 0.30


  
define mc = Character("Main Character")
define li = Character("Love Interest")

default persistent.know_age = False
  
label start:

    show screen StatInfo

    scene black with dissolve
    mc "Hey honey, what's your age?"
    li "Wouldn't you like to know!"  # Click Stats and you won't see her age
    mc "Come on! I need to know if you are legal..."
    li "Damn right I am legal! I'm 21!"
    $ persistent.know_age = True
    mc "Well then, want to come party with me?"  # Click Stats now and it will show her age
    mc "I don't have anything more to say."

    return

This will display a simple textbutton named "STATS" in the upper left of your screen (same xalign as the stat data you wanted). You display it by using the show screen StatInfo . That will stay showing until it is hidden using hide screen StatInfo or until another screen is shown over top of it. Normal scene transisitons and images won't override it.

I'm assuming you don't want the Stats data on screen all the time, so having an unobtrusive button in one of the corners (I feel) is better. The action ToggleScreen( "StatDetails" ) toggles showing the StatDetails screen. Also, instead of putting all that text formatting over and over again, I just put it in a style prefix. I also put the x and y alignments there as well. That's what the style_prefix "StatStyle" does in your StatDetails screen.

The default persistent.know_age = False creates that persistent variable for tracking if the MC knows the age of this character. Of course you can change the naming, but the persistent. prefix is what makes it a persistent variable that stands outside of the game saves and is carried over even when you start a new game.

Try it in a test project.... When you first run the game, click on the STAT textbutton and it will say "Age: Unknown". Then advance the dialogue and when she says she's 21, click it again and it will now say "Age: 21". Now exit the game and start a new game and click STATS right at the beginning and Ren'py remembers that persistent variable and will show "Age: 21"

When you are comfortable with the basics, you can really jazz things up with vbox's and hbox's to position elements and using imagebuttons instead of text, etc, etc... This is where Ren'py shines, IMO. It has a lot of functions that are easy for people without a programming background to grasp and use to make a good VN.

EDITED: to add the part about show screen
 
Last edited:
  • Like
Reactions: osanaiko

DanStory

Newbie
Sep 30, 2021
50
66
Python:
Code:
screen StatInfo():

    vbox:
        xalign 0.04
        yalign 0
        textbutton "STATS" action ToggleScreen( "StatDetails" )

screen StatDetails():
    style_prefix "StatStyle"

    if persistent.know_age:
        text "Age: 21"
    else:
        text "Age: Unknown"

style StatStyle_text:
    size 30
    font "HeyMarch-MV0Or.ttf"
    color "#ffff00"
    xalign 0.04
    yalign 0.30


 
define mc = Character("Main Character")
define li = Character("Love Interest")

default persistent.know_age = False
 
label start:

    show screen StatInfo

    scene black with dissolve
    mc "Hey honey, what's your age?"
    li "Wouldn't you like to know!"  # Click Stats and you won't see her age
    mc "Come on! I need to know if you are legal..."
    li "Damn right I am legal! I'm 21!"
    $ persistent.know_age = True
    mc "Well then, want to come party with me?"  # Click Stats now and it will show her age
    mc "I don't have anything more to say."

    return
well im using this
Code:
screen stats:
    imagemap:
        ground "images/stats/stats_idle.png"
        hover "images/stats/stats_hover.png"

        hotspot (1719, 7, 180, 99) action ShowMenu("relationship")
and stats for mc and relationship
Code:
screen relationship:
    imagemap:
        ground "images/stats/relationship_idle.png"
        hover "images/stats/relationship_hover.png"

        hotspot (872, 0, 191, 1078) action Return()
        hotspot (2, 1, 870, 1077) action ShowMenu("stats_mc"), Hide("relationship")
        hotspot (1064, 0, 856, 1077) action ShowMenu("andrea"), Hide("relationship")
and then the stats of ur friend
Code:
screen ashley():
    imagemap:
        ground "images/stats/ashley_idle.png"
        hover "images/stats/ashley_hover.png"

        text "{size=+30}{font=HeyMarch-MV0Or.ttf}Relationship{/font}{/size} : " xalign 0.04 yalign 0.10 #1
        text "{size=+30}{font=HeyMarch-MV0Or.ttf}[ashley_affection]{/font}{/size} " xalign 0.20 yalign 0.10
        text "{size=+30}{font=HeyMarch-MV0Or.ttf}Name{/font}{/size} : " xalign 0.04 yalign 0.20 #2
        if ashley_name:
            text "{size=+30}{font=HeyMarch-MV0Or.ttf}Ashley{/font}{/size} " xalign 0.13 yalign 0.20 #full andrea volkova (wolf)
        text "{size=+30}{font=HeyMarch-MV0Or.ttf}Age{/font}{/size} : " xalign 0.04 yalign 0.30 #3
        if ashley_age:
            text "{size=+30}{font=HeyMarch-MV0Or.ttf}20{/font}{/size} " xalign 0.11 yalign 0.30
        text "{size=+30}{font=HeyMarch-MV0Or.ttf}Height{/font}{/size} : " xalign 0.04 yalign 0.40 #4
        if ashley_height:
            text "{size=+30}{font=HeyMarch-MV0Or.ttf}170cm/5.57ft{/font}{/size} " xalign 0.14 yalign 0.40
        text "{size=+30}{font=HeyMarch-MV0Or.ttf}Weight{/font}{/size} : " xalign 0.04 yalign 0.50 #5
        if ashley_weight:
            text "{size=+30}{font=HeyMarch-MV0Or.ttf}62Kg/136.6Lbs{/font}{/size} " xalign 0.15 yalign 0.50

and this the bio bla bla... will unlock as the relationship with that person grows (not added yet)

        hotspot (1680, 962, 218, 104) action Hide("ashley"), ShowMenu("relationship")
        hotspot (1680, 464, 201, 146) action Hide("ashley"), ShowMenu("bella")
        hotspot (674, 454, 220, 151) action Hide("ashley"), ShowMenu("andrea")
I haven't added persistent yet
What do young think?
 

Turning Tricks

Rendering Fantasies
Game Developer
Apr 9, 2022
843
1,835
Well, I haven't played with imagemaps yet, so I can't comment on that part of your code, but I see two things missing right away. The opening and closing parenthesis for two of your screens is missing (screen relationship: should be screen relationship(): and same for the stats screen.

Might be worthwhile looking at vbox and hbox in Screen Language over at the renpy doc site. All that formatting code you use can be cleaned up a lot by just defining a style for your screen. You could set out the boxes where your stats data will be shown and then just put the formatting in a style. I believe it will work over an imagemap, although you might have to change zorder.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,193
14,923
Code:
screen ashley():
    imagemap:
        ground "images/stats/ashley_idle.png"
        hover "images/stats/ashley_hover.png"

        text "{size=+30}{font=HeyMarch-MV0Or.ttf}Relationship{/font}{/size} : " xalign 0.04 yalign 0.10 #1
        text "{size=+30}{font=HeyMarch-MV0Or.ttf}[ashley_affection]{/font}{/size} " xalign 0.20 yalign 0.10
        [...]
        hotspot (1680, 962, 218, 104) action Hide("ashley"), ShowMenu("relationship")
        hotspot (1680, 464, 201, 146) action Hide("ashley"), ShowMenu("bella")
        hotspot (674, 454, 220, 151) action Hide("ashley"), ShowMenu("andrea")
Using would be better than all those imagemap.

The text shouldn't be inside the imagemap block.

You should create a style, and apply it to the text statements, instead of multiplying the {size=+30}{font=HeyMarch-MV0Or.ttf} and their closing counterpart.
Depending if there's other unseen text or not in the screen you can even benefit from to not have to explicitly name the style for each text statement.

And, as said, all the screen declaration should have a parameter list, while / would probably ease the layout formatting.


Well, I haven't played with imagemaps yet,
And you have near to no reason to. imagebutton is way more flexible and optimised than the outdated imagemap approach.
 
  • Like
Reactions: Turning Tricks

DanStory

Newbie
Sep 30, 2021
50
66
Using would be better than all those imagemap.
Can you give me an example of imagebutton for 2 character display stats?
Its, like when you click on right arrow the screen will change to next char and when u click left arrow will show prev char then if u click back u'll back to the relationship.
cause i just wanna create status for characters relationship like that, i've tried using just now, but it's makes me confused cause i think the easiest way is using imagemap.

I think is the best for free roam cause u can add lot of feature there depending on where u wanna bring the players to explore.

You should create a style, and apply it to the text statements, instead of multiplying the {size=+30}{font=HeyMarch-MV0Or.ttf} and their closing counterpart.
I agree with u and i'll make the style later, thank you for ur advice.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,193
14,923
Can you give me an example of imagebutton for 2 character display stats?
/!\ Wrote on the fly as pure demonstration /!\
It's a bit diner time and I have a headache, so I'll be basic.
Python:
screen relationship():

    default who = 0
    default screenList = [ "ashley", "andrea" ]

    hbox:
        imagebutton:
            idle "prev.png"
            action If( who > 0, SetScreenVariable( "who", who - 1 ), SetScreenVariable( "who", len( screenList ) - 1 ) )  
        imagebutton:
            idle "ashley.png"
            action SetScreenVariable( "who", 0 )
        imagebutton:
            idle "andrea.png"
            action SetScreenVariable( "who", 1 )
        imagebutton:
            idle "next.png"
            action If( who < len( screenList ) - 1, SetScreenVariable( "who", who + 1 ), SetScreenVariable( "who", 0 ) )  

    if who:
        use expression screenList[who]

screen ashley():
    [...]

screen andrea():
    [...]
If my brain is still working, it should works.


I'll not comment more, headache make me grumpier...