Name display error

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
User avatar
seafoamsky
Newbie
Posts: 6
Joined: Sun Jan 28, 2018 11:25 pm
Contact:

Name display error

#1 Post by seafoamsky »

I am trying to add an option to choose your name and then display it in the sample text in a brand new project. But for some reason, I get this error:
File "game/script.rpy", line 35: invalid syntax
I followed the tutorial on the documentation and ended up with this:

Code: Select all

python:
    mcname = renpy.input("What is your name?")
    mcname = mcname.strip()
    if not mcname:
        mcname = "Hitoshi"

    # These display lines of dialogue.

    e "You've created a new Ren'Py game, [mcname]."

    e "Once you add a story, pictures, and music, you can release it to the world!"
Can someone help? I'm relatively new, so I may have just made a silly mistake.

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Name display error

#2 Post by IrinaLazareva »

This is indentation error

Code: Select all

label start:
    python:
        mcname = renpy.input("What is your name?")
        mcname = mcname.strip()
        if not mcname:
            mcname = "Hitoshi"
            
    # These display lines of dialogue.
    
    e "You've created a new Ren'Py game, [mcname]."
    e "Once you add a story, pictures, and music, you can release it to the world!"

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Name display error

#3 Post by IrinaLazareva »

by the way, the code can be optimized:

Code: Select all

label start:            
    $ mcname = renpy.input("What is your name?").strip() or "Hitoshi"
    
    e "You've created a new Ren'Py game, [mcname]."
    e "Once you add a story, pictures, and music, you can release it to the world!"    

User avatar
seafoamsky
Newbie
Posts: 6
Joined: Sun Jan 28, 2018 11:25 pm
Contact:

Re: Name display error

#4 Post by seafoamsky »

It works just fine now. Thank you!

Post Reply

Who is online

Users browsing this forum: No registered users