Ren'Py Code Question...

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
xxAkixx
Newbie
Posts: 1
Joined: Sun Feb 23, 2014 9:26 pm
Contact:

Ren'Py Code Question...

#1 Post by xxAkixx »

I am still fairly new to Ren'Py, and so far I am loving it. :lol:
I am a little stuck in the coding; I am trying to let players enter there names. After it finally stopped showing error codes for the user interaction, it keeps saying there is indentation mismatch in line 41. I used spaces, and it's still showing this error.
why? what am I doing wrong?

Code: Select all

$ player_name = player_name.strip()
# The .strip() instruction removes any extra spaces the player 
# may have typed by accident.

#  If the player can't be bothered to choose a name, then we
#  choose a suitable one for them:
      if player_name == "":
        $ player_name="Mei Jones"

# And get a nostalgic sigh from Seasons of Sakura fans!
    
# Now the other characters in the game can greet the player.
    
    p "I am [player_name]."   #The error is here.
    un "I am Alban Joesphs, Founder of Joesphs Designs Inc. I will be interviewing you."
    
    return
Attachments
This the a picture of the error I keep getting.
This the a picture of the error I keep getting.

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Ren'Py Code Question...

#2 Post by Asceai »

You have an indentation mismatch. The 'if player_name == "":' is preceded by 6 spaces, while 'p "I am [player_name]."' is preceded by only 4 spaces. Statements at the same 'level' must be indented at the same level. Either remove two spaces from the if statement or add two spaces to the "I am [player_name]." statement.

User avatar
Showsni
Miko-Class Veteran
Posts: 563
Joined: Tue Jul 24, 2007 12:58 pm
Contact:

Re: Ren'Py Code Question...

#3 Post by Showsni »

You have 6 spaces before the if player_name line and only 4 before the p "I am... line. They need to line up; I'd probably stick with 4 throughout. In fact, do those lines need to be indented at all?

Code: Select all

$ player_name = player_name.strip()
if player_name == "":
    $ player_name="Mei Jones"
    
p "I am [player_name]."   
un "I am Alban Joesphs, Founder of Joesphs Designs Inc. I will be interviewing you."
    
return

Post Reply

Who is online

Users browsing this forum: No registered users