Page 1 of 1

What's wrong with this script?

Posted: Mon Mar 05, 2012 1:22 am
by mechahotwings
Basically, I want to make so that if the player doesn't input a name and if he is male, his name will become Jack. And if the player didn't enter a name and if she is female, her name is Sarah. I can't for the life of me see what's wrong with what I've written.

Code: Select all

"Are you male or female?"
    menu:
        "Male":
                $ gender = "male"
        "Female":
                $ gender = "female"
    "What is your name?"
    $ player_name = renpy.input ("What is your name?")
    $ player_name = player_name.strip()
    if $ gender=="male" :
        if player_name == "":
                $ player_name="Jack"
    if $ gender== "female" :
        if player_name == "":
            $ player_name="Sarah"

Re: What's wrong with this script?

Posted: Mon Mar 05, 2012 4:01 am
by Taleweaver
First of all, the indentations are off. WAY off. Also, I think the

if $ gender ==

things should be

if gender ==


There's also a way in the Ren'Py Cookbook to do this.

Re: What's wrong with this script?

Posted: Mon Mar 05, 2012 7:37 pm
by mechahotwings
Taleweaver wrote:First of all, the indentations are off. WAY off. Also, I think the

if $ gender ==

things should be

if gender ==


There's also a way in the Ren'Py Cookbook to do this.
Thank you so much! :mrgreen: That I fixed one problem, however, it led to another. I've been putting in the player name thing into the code like the example in the cookbook, however, it says that there is an error on the line. What would the error be?

Code: Select all

define m = Character ( 'Me', color = "# ffffff" )
label start:
    "Are you male or female?"
    menu:
        "Male":
                $ gender = "male"
        "Female":
                $ gender = "female"
    "What is your name?"
    $ player_name = renpy.input ("What is your name?")
    $ player_name = player_name.strip()
if gender=="male" :
    if player_name == "":
        $ player_name="Jack"
if gender== "female" :
        if player_name == "":
            $ player_name="Sarah"
m "My name is  %(player_name).  I've recently been hired as a journalist for a small-time newspaper company."

Re: What's wrong with this script?

Posted: Mon Mar 05, 2012 7:58 pm
by Camille
The new syntax makes it so you should use [player_name] instead of %(player_name).

Re: What's wrong with this script?

Posted: Mon Mar 05, 2012 8:23 pm
by mechahotwings
Camille wrote:The new syntax makes it so you should use [player_name] instead of %(player_name).
So the cookbook is a little out of date, then. Thank you, as well. :D