Dumb noob question about name inputs

CarbonBlue

Developer of Unleashed
Game Developer
Oct 25, 2018
1,142
7,740
I am a noob to coding. Went through the ren'py tutorial and I'm starting to build my game, and I'm actually doing ok. However, I'm having some troubles. For each character at their introduction I ask the player if they want to change the character's name with a Yes/No. If they choose yes, I want to add an input for the name. That far I've gotten. Unfortunately it gives me an error.

Code:
    scene scene1_2

    "This is Mrs. Kelly. Her default name is Olivia. Would you like to change her name?"

    menu:

        "Yes":
            python:
                olivia_name = renpy.input(_("What is her name?"))

                olivia_name = name.strip() or __("Olivia")


        "No":
            jump olivia_name_done

    label olivia_name_done:
It returns an error that name is not defined. If anyone could help I'd appreciate it.
 

Winterfire

Forum Fanatic
Respected User
Game Developer
Sep 27, 2018
5,046
7,388
define Olivia = Character("[olivia_name]", color="#c8ffc8", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])

$olivia_name = renpy.input("What is her name?", "Olivia", None, None, 10)


Something like this should work, you need to define it somewhere.

-edit-
To "use" it you would write:

Olivia "I said a line"
 
  • Like
Reactions: CarbonBlue

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,361
15,271
I don't know a lot about ren'py but you are calling the strip() method on a variable called 'name' which is not defined because you named your variable 'olivia_name'.
Which is effectively the cause of the error.


$olivia_name = renpy.input("What is her name?", "Olivia", None, None, 10)
To fully reflect OP initial code, don't forget to strip the result :
$olivia_name = renpy.input("What is her name?", "Olivia", None, None, 10).strip()
 
  • Like
Reactions: CarbonBlue

CarbonBlue

Developer of Unleashed
Game Developer
Oct 25, 2018
1,142
7,740
OK wait maybe it's not quite working. If I choose No and don't change their names, it gives me a KeyError u/'olivia_name'. I apologize for my dumbness here, but is there a way to define the name after the name change, whether it was changed or not, so in my script I can write "o (for olivia or whatever is the new name) "hi blah blah"?
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,272
22,420
did you try the pass command?
Python:
menu:
    "Yes":
        do stuff
    "No":
        pass
 

CarbonBlue

Developer of Unleashed
Game Developer
Oct 25, 2018
1,142
7,740
Did not know about the pass command, I used a jump, which did the same thing. But I think the problem is in defining the name after I get past the option to change the name and the name change. Right now I have:
Code:
    menu:

        "Yes":
            python:
                angel_name = renpy.input("What is her name?", "Angel", None, None, 10).strip()

        "No":
            pass

    label angel_name_done:

        define a = Character("[angel_name]", color="#c8ffc8", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])
But then when I do a new scene and "a "says something here"" it returns a KeyError.
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,272
22,420
define the character variables before the start label
Python:
define a = Character("Blabla")

...

label start:
    menu:
        "Yes":
            do stuff
        "no"
            pass
       
label nextScene:
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,272
22,420
Code:
...

    label angel_name_done:

        define a = Character("[angel_name]", color="#c8ffc8", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])
^there you have it in the label :p
 

CarbonBlue

Developer of Unleashed
Game Developer
Oct 25, 2018
1,142
7,740
I appreciate the help! Unfortunately, nope, that's not it either, lol.
 

CarbonBlue

Developer of Unleashed
Game Developer
Oct 25, 2018
1,142
7,740
Code:
define s = Character("[shannon_name]", color="#06DE10", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])
define a = Character("[angel_name]", color="#A165F1", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])
define o = Character("[olivia_name]", color="#c8ffc8", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])
define m = Character("[maeve_name]", color="#c8ffc8", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])

define short_dissolve = Dissolve(0.5)
define medium_dissolve = Dissolve(1.0)

# The game starts here.

label start:

    # Show a background. This uses a placeholder by default, but you can
    # add a file (named either "bg room.png" or "bg room.jpg") to the
    # images directory to show it.

    scene scene1_1

    # This shows a character sprite. A placeholder is used, but you can
    # replace it by adding a file named "eileen happy.png" to the images
    # directory.

    # These display lines of dialogue.

    "Olivia" "OK girls I'm heading out to pick him up!"

    scene scene1_2

    "This is Mrs. Kelly. Her default name is Olivia. Would you like to change her name?"

    menu:

        "Yes":
            python:
                olivia_name = renpy.input("What is her name?", "Olivia", None, None, 10).strip()

        "No":
            pass

    #label olivia_name_done:

    #define o = Character("[olivia_name]", color="#c8ffc8", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])


    scene scene1_3

    "Angel" "Pick who up, Mrs. Kelly?"

    "This is Miss Davis, a friend of the family. Her default name is Angel. Would you like to change her name?"

    menu:

        "Yes":
            python:
                angel_name = renpy.input("What is her name?", "Angel", None, None, 10).strip()

        "No":
            pass


    #define a = Character("[angel_name]", color="#c8ffc8", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])


    scene scene1_4

    "Shannon" "Whom."

    scene scene1_5

    "This is the youngest daughter of the family. Her default name is Shannon. Would you like to change her name?"

    menu:

        "Yes":
            python:
                shannon_name = renpy.input("What is her name?", "Shannon", None, None, 10).strip()

                shannon_name = shannon_name.strip() or __("Shannon")

        "No":
            pass

    #label shannon_name_done:

    #define s = Character("[shannon_name]", color="#c8ffc8", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])


    scene scene1_6

    a "Bitch."
That a "Bitch." is where it dies. Please excuse all the #'s as those are various attempts at fixes, heh.
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,272
22,420
Python:
define s = Character("[shannon_name]", color="#06DE10", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])
define a = Character("[angel_name]", color="#A165F1", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])
define o = Character("[olivia_name]", color="#c8ffc8", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])
define m = Character("[maeve_name]", color="#c8ffc8", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])

define short_dissolve = Dissolve(0.5)
define medium_dissolve = Dissolve(1.0)

label start:

    scene scene1_1

    "Olivia" "OK girls I'm heading out to pick him up!"

    scene scene1_2

    "This is Mrs. Kelly. Her default name is Olivia. Would you like to change her name?"

    menu:

        "Yes":
            $ olivia_name = renpy.input("What is her name?", "Olivia", None, None, 10).strip()

        "No":
            pass


    scene scene1_3

    "Angel" "Pick who up, Mrs. Kelly?"

    "This is Miss Davis, a friend of the family. Her default name is Angel. Would you like to change her name?"

    menu:

        "Yes":
            $ angel_name = renpy.input("What is her name?", "Angel", None, None, 10).strip()

        "No":
            pass


    scene scene1_4

    "Shannon" "Whom."

    scene scene1_5

    "This is the youngest daughter of the family. Her default name is Shannon. Would you like to change her name?"

    menu:

        "Yes":
            $ shannon_name = renpy.input("What is her name?", "Shannon", None, None, 10).strip()

        "No":
            pass


    scene scene1_6

    a "Bitch."
 

polywog

Forum Fanatic
May 19, 2017
4,062
6,263
First ask the question "Do you want to name the characters or use default names?"
use default names as default
it's annoying as hell to be asked to name a bunch of characters, who you know nothing about all at once.
introduce the characters, and give a little info first before asking what they should be called.
 
  • Like
Reactions: recreation

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,692
Have you tried using "default" instead of "define"?

Code:
default s = Character("[shannon_name]", color="#06DE10", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])
default a = Character("[angel_name]", color="#A165F1", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])
default o = Character("[olivia_name]", color="#c8ffc8", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])
default m = Character("[maeve_name]", color="#c8ffc8", who_outlines=[ (1, "#000000") ], what_outlines=[ (1, "#000000") ])

define short_dissolve = Dissolve(0.5)
define medium_dissolve = Dissolve(1.0)

# The game starts here.

label start:

    # Show a background. This uses a placeholder by default, but you can
    # add a file (named either "bg room.png" or "bg room.jpg") to the
    # images directory to show it.

    scene scene1_1

    # This shows a character sprite. A placeholder is used, but you can
    # replace it by adding a file named "eileen happy.png" to the images
    # directory.

    # These display lines of dialogue.

    "Olivia" "OK girls I'm heading out to pick him up!"

    scene scene1_2

    "This is Mrs. Kelly. Her default name is Olivia. Would you like to change her name?"

    menu:

        "Yes":
           $  olivia_name = renpy.input("What is her name?", "Olivia", None, None, 10).strip()

        "No":
            pass

    #label olivia_name_done:


    scene scene1_3

    "Angel" "Pick who up, Mrs. Kelly?"

    "This is Miss Davis, a friend of the family. Her default name is Angel. Would you like to change her name?"

    menu:

        "Yes":
            $ angel_name = renpy.input("What is her name?", "Angel", None, None, 10).strip()

        "No":
            pass


    scene scene1_4

    "Shannon" "Whom."

    scene scene1_5

    "This is the youngest daughter of the family. Her default name is Shannon. Would you like to change her name?"

    menu:

        "Yes":
            $ shannon_name = renpy.input("What is her name?", "Shannon", None, None, 10).strip()

                shannon_name = shannon_name.strip() or __("Shannon")

        "No":
            pass

    #label shannon_name_done:


    scene scene1_6

    a "Bitch."
In my code, the only character that can be renamed and uses a variable instead of text, I have it in "default", the others in "defines".

Sorry if I'm wrong because I'm not a great expert, but...
You use "define" for a constant, you can't change it if you don't use the command define again.
Using "default", it will be a variable that will react to the changes you indicate.
 

CarbonBlue

Developer of Unleashed
Game Developer
Oct 25, 2018
1,142
7,740
Deleted the rpyc files and still doesn't work. I started a new project and pasted only your code and get the same thing - note that this only happens if I select "no" for changing Angel's name (and in the other code it happens for the other women if I choose No on their name changes too).