Player-name Input

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
18point6y
Newbie
Posts: 2
Joined: Fri Jun 01, 2018 8:30 am
Contact:

Player-name Input

#1 Post by 18point6y »

Hello, I just created an account here and I would like to ask a (probably) very basic question.

I wanna know how to let the player chose his/her name.

I have tried to search all over and I could only find codes like the following:

Code:
define e = Character("[name]")

# The game starts here.
label start:
$ name = renpy.input("What's your name?")
$ name = name.strip()
e"Hello! I'm [name]!"

Which does not work. This code is even in the Ren'Py page itself (that is outdated).

Could someone please help me with that? Thanks in advance.

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Player-name Input

#2 Post by kivik »

Can you clarify what you mean when you say it doesn't work?

The code above makes character e's name whatever the player inputs when displayed. So we need to know what makes you say that it doesn't - e.g. is your player a different character? Can you show us your code?

User avatar
erickcire95
Regular
Posts: 33
Joined: Tue Dec 26, 2017 7:38 pm
Contact:

Re: Player-name Input

#3 Post by erickcire95 »

Code: Select all

define e = Character("[name]")

# The game starts here.
label start:
$ name = Character(renpy.input("What's your name?"))
e"Hello! I'm [name]!"
you are missing the character part when you ask for input

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Player-name Input

#4 Post by Imperf3kt »

erickcire95 wrote: Fri Jun 01, 2018 9:06 am

Code: Select all

define e = Character("[name]")

# The game starts here.
label start:
    $ name = Character(renpy.input("What's your name?"))
    e"Hello! I'm [name]!"
you are missing the character part when you ask for input
Indentation also matters.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Player-name Input

#5 Post by kivik »

erickcire95 wrote: Fri Jun 01, 2018 9:06 am

Code: Select all

define e = Character("[name]")

# The game starts here.
label start:
$ name = Character(renpy.input("What's your name?"))
e"Hello! I'm [name]!"
you are missing the character part when you ask for input

Doesn't that make the variable name a Character??

The way the code worked was that a Character was created (called e) whose name is an interpolated string: "[name]" so whatever the variable name is, it'll be used as e's name.

18point6y
Newbie
Posts: 2
Joined: Fri Jun 01, 2018 8:30 am
Contact:

Re: Player-name Input

#6 Post by 18point6y »

erickcire95 wrote: Fri Jun 01, 2018 9:06 am

Code: Select all

define e = Character("[name]")

# The game starts here.
label start:
$ name = Character(renpy.input("What's your name?"))
e"Hello! I'm [name]!"
you are missing the character part when you ask for input
Thank you lots, that was it.
Unfortunately, I did not found any code with that "Character" part, so I hope this thread helps any newcomers with the same problem.

Also, thanks to everyone that tried to assist. :)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], LuckyT, tim640