Ren'Py Coding help for Age check

Uncle Loco

Engaged Member
Game Developer
Apr 28, 2020
3,399
10,759
Hey all.

I am trying to address an issue people complained about that tested my game. I have an age check in the beginning of my story. I would like it if the user passes the check once they don't need to see the screens again. I have messed around with the code and keep getting various error messages. Any help would be great.


1670462865303.png
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,368
15,282
I have an age check in the beginning of my story.
No, it isn't at the beginning of your story, it's previous to the main menu.


I would like it if the user passes the check once they don't need to see the screens again.
Then why not pass it at the very starts of the "start" label, like most games do ? It would be more logical than having it so early.



Now that this is said, you just need to rely on a persistent value.
Python:
label splashscreen:
    # If the player already passed the check, continue loading the game.
    if persistent.ageChecked == True:
        return

    scene black with dissolve
    [...]
    menu:
        "Yes, I am 18 or older":
            # Ok, the player is over 18
            $ persistent.ageChecked = True
            return
        "No, I am under 18":
            # Do NOT set the persistent value, else the player will be forever trapped out.
            $ renpy.quit()
And what with all those pause ? The splash screen is supposed to be automatic, I wonder how many people stay stuck for seconds before they understood that they need to click.
 

coffeeaddicted

Well-Known Member
Apr 13, 2021
1,765
1,432
No, it isn't at the beginning of your story, it's previous to the main menu.




Then why not pass it at the very starts of the "start" label, like most games do ? It would be more logical than having it so early.



Now that this is said, you just need to rely on a persistent value.
Python:
label splashscreen:
    # If the player already passed the check, continue loading the game.
    if persistent.ageChecked == True:
        return

    scene black with dissolve
    [...]
    menu:
        "Yes, I am 18 or older":
            # Ok, the player is over 18
            $ persistent.ageChecked = True
            return
        "No, I am under 18":
            # Do NOT set the persistent value, else the player will be forever trapped out.
            $ renpy.quit()
And what with all those pause ? The splash screen is supposed to be automatic, I wonder how many people stay stuck for seconds before they understood that they need to click.

This is genius.

The more i think about, the more obvious it becomes. :eek:
 

Uncle Loco

Engaged Member
Game Developer
Apr 28, 2020
3,399
10,759
And what with all those pause ? The splash screen is supposed to be automatic, I wonder how many people stay stuck for seconds before they understood that they need to click.

Sorry I wasn't clear on the placement, or what I exactly really need. Sorry, I am still new to coding, and seeing error messages gets frustrating.

I have 2 images that I want to appear no matter what during the splashscreen so the player sees/reads them (which is why there are pauses). Then the age check but I want the user to only have to see that one time if they pass the check. I also have images I want to appear with the age check for both passed and failed checks.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,368
15,282
I have 2 images that I want to appear no matter what during the splashscreen so the player sees/reads them (which is why there are pauses). Then the age check but I want the user to only have to see that one time if they pass the check. I also have images I want to appear with the age check for both passed and failed checks.
Well, now you know how to do it.
 

Creiz

Well-Known Member
Game Developer
Sep 18, 2018
1,293
3,013
Do you really need to do an actual age check, though?

Isn't a warning enough? "If you aren't at least 18 (or legal age in your country) then close this game." or something like that.

Personally I just put it after my splash screens, along with other disclaimers and be done with it.
 
  • Like
Reactions: gojira667

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,296
3,952
Do you really need to do an actual age check, though?

Isn't a warning enough? "If you aren't at least 18 (or legal age in your country) then close this game." or something like that.

Personally I just put it after my splash screens, along with other disclaimers and be done with it.
There's no absolute clear answer to this. Most important would be "what is the minimum expected effort to prevent minors from accessing this adults only work" in the jurisdiction of the developer. And the answer to that question would depend on local law and the existing body of case-law. Different countries have different standards
 
  • Like
Reactions: Creiz

Turning Tricks

Rendering Fantasies
Game Developer
Apr 9, 2022
992
2,094
The way I am doing this in my game atm is that I have a splash screen, which will only show if you haven't already played and said you were of age.

Then I have a disclaimer section where the legal shit is shown, with pauses designed to allow a slow reader to read it, but you can still click through if you want.

And then I have the age check in my script, near the beginning of the content.

As for 'Do we have to?" - The way i see it, is that by having to actually click the YES, you are doing an action that shows you must have seen the warning. If you just had it show and then advance, some lawyer type could say the player looked away or may not have had time to read it or that you had a bug in the code, etc. Making it a physical interaction on the player' part is a way to avoid these loopholes.

Anyhow, my code looks like this. I'm still a noob at this so it's a work in progress and I tend to use booleans for my conditional statements, especially the persistent variables.

Python:
label splashscreen:

    if persistent.age_of_consent:
        jump disclaimer

    scene black
    $ renpy.movie_cutscene("gui/splash.webm")
    stop sound
    pause 2.0

label disclaimer:

    show disclaimer1 with dissolve
    pause 20.0

    show disclaimer2 with dissolve
    pause 15.0

    $ MainMenu(confirm=False)()

label start:

    scene black with dissolve

    if persistent.age_of_consent:
        jump new_content
    elif not persistent.age_of_consent:
        jump intro


label intro:

    menu:
        "Are you legal Age of Consent for where you Live?"

        "Yes":
            $ persistent.age_of_consent = True
        "No":
            $ renpy.quit()
EDIT: Just for shits and giggles, I changed the code I use above to be more in-line with what the OP seemed to want to do... Forgive me, I've done ~12,000 lines of code in the last week and I am a bit loopy and just blowing some steam off. just having fun ... :p


Python:
label splashscreen:

    if persistent.age_check:
        jump disclaimer

    scene black
    $ renpy.movie_cutscene("gui/splash.webm")
    stop sound
    pause 2.0

label disclaimer:

    show disclaimer1 with dissolve
    pause 20.0

    show disclaimer2 with dissolve
    pause 15.0

    $ MainMenu(confirm=False)()

label start:

    scene black with dissolve

    if persistent.age_check:
        jump to_wherever_your_game_goes_from_here
    elif not persistent.age_check:
        jump intro


label intro:

    menu:
        "Are you legal Age of Consent for where you Live and do you always tell the truth to your computer?"

        "Yes, I am 18 or older":
            $ persitent.age_check = True
            scene agegood with dissolve
            pause ## so the honest adult can bask in the glow of telling the truth to his computer      
        "No, I hacked my brother's computer and I'm only 10":
            $ persistent.age_check = False
            scene agebad with dissolve
            pause ## so the immature degenerate can absorb the screen and mend his wicked ways
            $ renpy.quit()

    jump to_wherever_your_game_goes_from_here
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,368
15,282
Python:
label splashscreen:

    if persistent.age_of_consent:
        jump disclaimer

    scene black
    $ renpy.movie_cutscene("gui/splash.webm")
    stop sound
    pause 2.0

label disclaimer:

    show disclaimer1 with dissolve
    pause 20.0

    show disclaimer2 with dissolve
    pause 15.0

    $ MainMenu(confirm=False)()
There's two issues with this code:

Firstly, the "splashscreen" label is not ended by a branching, so the "disclaimer" will be proceeded every time. By itself it's just half a problem, thanks to the implicit jump and order of the labels.

But the second issue is more a problem, why this horrible $ MainMenu( confirm=False)() ?
It's not how you should trigger a screen action when used outside of a screen. There's the function made especially for this. And in top of this, you are seriously messing with Ren'Py by doing it this way. Like said when the "splashscreen" is presented, and shown in , it's that must be used here. The fact that you jump to "disclaimer" change nothing to the flow, Ren'Py is still expecting you to return from the label it just called.
By chance the splashscreen is called late in the starts process, but Ren'Py still have few things to do after this ; things that aren't done because you decided to hijack the natural process.
 

Turning Tricks

Rendering Fantasies
Game Developer
Apr 9, 2022
992
2,094
There's two issues with this code:

Firstly, the "splashscreen" label is not ended by a branching, so the "disclaimer" will be proceeded every time. By itself it's just half a problem, thanks to the implicit jump and order of the labels.

But the second issue is more a problem, why this horrible $ MainMenu( confirm=False)() ?
It's not how you should trigger a screen action when used outside of a screen. There's the function made especially for this. And in top of this, you are seriously messing with Ren'Py by doing it this way. Like said when the "splashscreen" is presented, and shown in , it's that must be used here. The fact that you jump to "disclaimer" change nothing to the flow, Ren'Py is still expecting you to return from the label it just called.
By chance the splashscreen is called late in the starts process, but Ren'Py still have few things to do after this ; things that aren't done because you decided to hijack the natural process.
First of all, I had no idea about renpy.run() being the better way to call the main menu. As a thousand people have already said on here and on other forums, Ren'py is not known for it's user friendly documentation. And before you get in a huff and say it's perfectly understandable to coders such as yourself ... Ren'py is marketed as an engine that allows "Beginners" to make their own VN's. I wrote that section like 6 months ago, so I can't recall where it came from, and it's worked for thousands of people that downloaded my Prologue with not a single bug report... so, honestly, it's a non-issue to me. Heck, I just read a post by you yesterday where you praised the rock solid backwards compatibility of Ren'py and how they never actually remove anything, only deprecate it. In any case, I changed it to the more correct and newer function. Thanks.

Secondly, I had a jump to exit the splashscreen block but I think I cut it off when I cut & paste into this thread post. However, I see nothing in the Splashscreen docs you linked that says you have to use a return and only a return to exit that block. In fact, that doc even mentioned being able to use the same Splashscreen code in any other part of your game. What I have found is dozens of instances where people have used jump from a splashscreen block to do something before the main menu loads. And --- again --- this is code that has worked for 6 months or so.

I rarely use call and return, unless it's a block that gets run quick and returns fast, as I have read about stack overflow and how calls can keeping piling on. If I use return in the splashscreen block, as you say, it sends me to the main menu before the legal disclaimers are shown, which is not what I want. I want those legal screens to show right after the splashscreen (unless the player has already been through the "Am I old enough" condition check).

Honestly, if you actually know what the "natural process" of Ren'py is, then I would fucking love to see you write a book on just what that process is and how to follow it, so I can try not to hijack it , as you say. Because every single time I see devs on here discussing ways to do something in Ren'py, I also see half a dozen different ways to do the same thing. I understand that part of the issue is that, under it's hood, Ren'py is a variation of Python, but that still doesn't change the fact that (1) there seems to be at least two ways to do most functions (Ren'Py simple and Python complex) and (2) the documentation provided for Ren'py majorly sux.

Oh, I guess you could add a third issue... 90% of the stuff on the net that you can Google for Ren'py is out of date.

Honestly AON, you've been a great help to me in the past (under my personal account) but this Holier than thou attitude on here gets a bit tiring...
 
Last edited: