[Solved] Naming the Character Input Issue

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
Katy133
Miko-Class Veteran
Posts: 704
Joined: Sat Nov 16, 2013 1:21 pm
Completed: Eight Sweets, The Heart of Tales, [redacted] Life, Must Love Jaws, A Tune at the End of the World, Three Guys That Paint, The Journey of Ignorance, Portal 2.5.
Projects: The Butler Detective
Tumblr: katy-133
Deviantart: Katy133
Soundcloud: Katy133
itch: katy133
Location: Canada
Contact:

[Solved] Naming the Character Input Issue

#1 Post by Katy133 »

I'm trying to figure out how to let the player choose the characters name. I want to make it so that if the player inputs the name "Hero" OR "Hiro," it's changed to, say, Hana. If they pick "Moo" or "Jane," that results in other name changes.

I currently have as the code:

Code: Select all

label start:
    $ name = renpy.input("Her name was...", length=10)

    $ name = name.strip()

    #  If the player can't be bothered to choose a name, then we
    #  choose a suitable one for them:
    if name == "Hero" or "Hiro": #<--This bit is the issue.
        $ name="Hana"
        "Her name was [name]. "
        jump after_name
        
    elif name == "Moo":
        $ name="Moore"
        "Her name was [name]."
        jump after_name
        
    else name == "Jane":
        $ name="Jade"
        "Her name was [name]."
        jump after_name
However, when I tested this, if I input Moo or Jane or any name, I'll always get the "Hana" result. How do I write the "Hero or Hiro" section of the script so that it works properly?

I know that I can use multiple labels/jumps to remove the "or" in the script altogether, like this:

Code: Select all

label start:
    $ name = renpy.input("Her name was...", length=10)

    $ name = name.strip()

    #  If the player can't be bothered to choose a name, then we
    #  choose a suitable one for them:
    if name == "Hero":
        jump hana_name
  
    if name == "Hiro":
        jump hana_name
              
    label hana_name:
        $ name="Hana"
        "Her name was [name]."
        jump after_name
BUT, I don't want to do this, since I've got a database with many, many different names, making this way too complex to code in an organised way.

Any ideas?
Last edited by Katy133 on Thu Aug 24, 2017 10:39 pm, edited 1 time in total.
ImageImage

My Website, which lists my visual novels.
Become a patron on my Patreon!

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Naming the Character Input Issue

#2 Post by trooper6 »

if name == "Hiro" or name == "Hana"
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Katy133
Miko-Class Veteran
Posts: 704
Joined: Sat Nov 16, 2013 1:21 pm
Completed: Eight Sweets, The Heart of Tales, [redacted] Life, Must Love Jaws, A Tune at the End of the World, Three Guys That Paint, The Journey of Ignorance, Portal 2.5.
Projects: The Butler Detective
Tumblr: katy-133
Deviantart: Katy133
Soundcloud: Katy133
itch: katy133
Location: Canada
Contact:

Re: Naming the Character Input Issue

#3 Post by Katy133 »

trooper6 wrote: Thu Aug 24, 2017 9:46 pm if name == "Hiro" or name == "Hana"
Ah, yes! if name == "Hiro" or name == "Hana": works great! Thank you. :D
ImageImage

My Website, which lists my visual novels.
Become a patron on my Patreon!

Post Reply

Who is online

Users browsing this forum: bonnie_641, Google [Bot]