age prompt

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
computerwhiz10101010
Newbie
Posts: 5
Joined: Sun Jan 07, 2024 3:54 am
Contact:

age prompt

#1 Post by computerwhiz10101010 »

i made this age prompt, but the game doesn't run! why?

Code: Select all

# The script of the game goes in this file.

# Declare characters used by this game. The color argument colorizes the
# name of the character.

define e = Character("Eileen")

# The game starts here.

label start:
    "Welcome to My Awesome Game!"
    call age_verification_prompt

    # Show a background. This uses a placeholder by default, but you can
    # add a file (named either "bg room.png" or "bg room.jpg") to the
    # images directory to show it.

    scene bg room

    # This shows a character sprite. A placeholder is used, but you can
    # replace it by adding a file named "eileen happy.png" to the images
    # directory.

    show eileen happy

    # These display lines of dialogue.

    e "You've created a new Ren'Py game."

    e "Once you add a story, pictures, and music, you can release it to the world!"

    # This ends the game.

    return

label age_verification_prompt:
    $ age_prompt = False  # Initialize the variable to False initially

    menu:
        "Are you 18 years old or older?":
            "Yes":
                $ age_prompt = True  # Set the variable to True if the user selects "Yes"
            "No":
                $ age_prompt = False  # Keep the variable as False if the user selects "No"

    if age_prompt:
        return  # Continue with the game if age_prompt is True
    else:
        "Sorry, you must be 18 or older to play this game."
        "Goodbye!"
        return  # Exit the game


I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/script.rpy", line 41: expected statement.
    "Yes":
         ^

File "game/script.rpy", line 43: expected statement.
    "No":
        ^

Ren'Py Version: Ren'Py 8.1.3.23091805
Sun Jan  7 03:10:02 2024

Another_Tom
Regular
Posts: 61
Joined: Mon Apr 24, 2023 9:06 am
Completed: Harold And The Witches
Projects: Steven On The Run
itch: dantom
Location: Germany
Contact:

Re: age prompt

#2 Post by Another_Tom »

computerwhiz10101010 wrote: Sun Jan 07, 2024 4:10 am i made this age prompt, but the game doesn't run! why?
There's just a syntax error in label age_verification_prompt.
Check this line:

Code: Select all

"Are you 18 years old or older?": # <- indicates to be a menu item, just delete the : it and it should work.
I would also recommend to default the age_prompt var outside of a label like:

Code: Select all

default age_prompt = False 
instead of just creating a temporary variable.


By the way as I looked at your nickname:
01000010 01111001 00100000 01110100 01101000 01100101 00100000 01110111 01100001 01111001 00101100 00100000 01111001 01101111 01110101 01110010 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00100000 01100011 01101111 01100100 01100101 00100000 01100100 01101111 01100101 01110011 01101110 00100111 01110100 00100000 01101101 01100001 01101011 01100101 00100000 01110011 01100101 01101110 01110011 01100101 00100000 00111010 01110000

computerwhiz10101010
Newbie
Posts: 5
Joined: Sun Jan 07, 2024 3:54 am
Contact:

Re: age prompt

#3 Post by computerwhiz10101010 »

i did as you said and it says i should not have deleted that colon

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/script.rpy", line 40: Line is followed by a block, despite not being a menu choice. Did you forget a colon at the end of the line?
    "Are you 18 years old or older?"
                                    ^

Ren'Py Version: Ren'Py 8.1.3.23091805
Sun Jan  7 11:18:19 2024

computerwhiz10101010
Newbie
Posts: 5
Joined: Sun Jan 07, 2024 3:54 am
Contact:

Re: age prompt

#4 Post by computerwhiz10101010 »

got it! you were right! and it was white space. thank you so much

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]