What's wrong with this script?

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
mechahotwings
Newbie
Posts: 4
Joined: Mon Mar 05, 2012 1:14 am
Contact:

What's wrong with this script?

#1 Post 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"

User avatar
Taleweaver
Writing Maniac
Posts: 3428
Joined: Tue Nov 11, 2003 8:51 am
Completed: Metropolitan Blues, The Loyal Kinsman, Daemonophilia, The Dreaming, The Thirteenth Year, Adrift, Bionic Heart 2, Secrets of the Wolf, The Photographer
Projects: The Pilgrim's Path, Elspeth's Garden, Secret Adventure Game!
Organization: Tall Tales Productions
Location: Germany
Contact:

Re: What's wrong with this script?

#2 Post 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.
Scriptwriter and producer of Metropolitan Blues
Creator of The Loyal Kinsman
Scriptwriter and director of Daemonophilia
Scriptwriter and director of The Dreaming
Scriptwriter of Zenith Chronicles
Scriptwriter and director of The Thirteenth Year
Scriptwriter and director of Romance is Dead
Scriptwriter and producer of Adrift
More about me in my blog
"Adrift - Like Ever17, but without the Deus Ex Machina" - HigurashiKira

mechahotwings
Newbie
Posts: 4
Joined: Mon Mar 05, 2012 1:14 am
Contact:

Re: What's wrong with this script?

#3 Post 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."

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: What's wrong with this script?

#4 Post by Camille »

The new syntax makes it so you should use [player_name] instead of %(player_name).

mechahotwings
Newbie
Posts: 4
Joined: Mon Mar 05, 2012 1:14 am
Contact:

Re: What's wrong with this script?

#5 Post 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

Post Reply

Who is online

Users browsing this forum: Google [Bot]