Player Character Name
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.
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.
Player Character Name
Okay, here it is: I'd like to be able to let the player enter their own name and use it as the name of the player character in my ren'ai game. I'm sure someone has done this already. Can anyone point me to the correct tutorial or forum post? Thank you
-
- Regular
- Posts: 33
- Joined: Sat Apr 22, 2006 6:00 am
- Projects: Angel of Love,Forgotten,War's Fate, D
- Location: Hungary
- Contact:
Re: Player Character Name
Where there's a will there's a way.
Project D:AoL
Special Thanks for their motivation and support to: BCS, Enerccio, mikey, monele, PyTom, yvanc, mugenjohncel, Sai
Project D:AoL
Special Thanks for their motivation and support to: BCS, Enerccio, mikey, monele, PyTom, yvanc, mugenjohncel, Sai
Re: Player Character Name
Thanks. Thinking something like this should probably be added to the cookbook for us n00bs.
Re: Player Character Name
I'm having trouble getting the code to work properly. What I want to do is have the character enter their first and last names in the program, and then plug the values into the conversations and into the text headers. The first part works fine, the second part not so well.
Here are the relevant lines of code.
The game returns:
So what am I doing wrong here?
Here are the relevant lines of code.
Code: Select all
init:
$ a = Character('%(firstname)s', color ="#5F9F9F")
$ a2 = Character('Little %(firstname)s', color ="#5F9F9F")
label start:
$ firstname = renpy.input ("What's your first name?", "Alex", length=20)
$ lastname = renpy.input ("What's your last name?", "Quill", length=20)
a "I dunno, I mean, why do we have to agree to this?"
So what am I doing wrong here?
Re: Player Character Name
Mmm... you'll have to use the "dynamic" parameter of Character for this, but I think it's limited to a single variable :
Now, if you want to have something like "Little Paul" displayed, you should make another Character pointing to, for example, "littlefirstname" and set littlefirstname as a combination of "Little " and firstname :
(my python is rusty, if it's not "+", it might be "&")
Code: Select all
init:
p = Character("firstname", dynamic=True)
label start:
$ firstname = "Paul"
p "Lalala."
Code: Select all
$ littlefirstname = "Little " + firstname
Re: Player Character Name
There's also a section (User interaction) in the Ren'py demo that seems to do exactly what you want to do.
You could always go into that section of the demo, click the button in the top right and see how it was done.
You could always go into that section of the demo, click the button in the top right and see how it was done.
Re: Player Character Name
Thank you both I didn't really think of taking a look at the demo like that. . . to be honest, I barely even looked at it before reading up on the tutorials and trying to figure things out I know, I know, RTMF.
-
- Regular
- Posts: 87
- Joined: Sat Jun 23, 2007 9:19 am
- Projects: ALICE.NET
- Location: The other end of the internet.
- Contact:
Re: Player Character Name
Not necessarily. "If [the dynamic argument to Character is] true, then name is interpreted as a string containing a python expression that is evaluated to yield the name of the character."monele wrote:Mmm... you'll have to use the "dynamic" parameter of Character for this, but I think it's limited to a single variable :
I tried the following code (using some resources from the Ren'Py Demo) and it works nicely:
Code: Select all
init:
image bg washington = "washington.jpg"
image eileen happy = "eileen_happy.png"
image eileen vhappy = "eileen_vhappy.png"
image eileen concerned = "eileen_concerned.png"
$ e = Character('knows_eileen and "Eileen" or "???"', dynamic=True, color="#c8ffc8")
label start:
$ knows_eileen = False
scene bg washington
show eileen happy
with dissolve
e "Hi! We're testing some uses of DynamicCharacter."
show eileen concerned
with dissolve
e "What? We haven't met?"
show eileen happy
with dissolve
$ knows_eileen = True
extend " Well, my name's Eileen."
show eileen vhappy
with dissolve
e "It's a pleasure to meet you!"
scene black
with dissolve
return
Code: Select all
init:
$ a = Character('firstname', dynamic=True, color ="#5F9F9F")
$ a2 = Character('"Little "+firstname', dynamic=True, color ="#5F9F9F")
Re: Player Character Name
Cool, I didn't expect a full python expression was possible ^_^
-
- Regular
- Posts: 87
- Joined: Sat Jun 23, 2007 9:19 am
- Projects: ALICE.NET
- Location: The other end of the internet.
- Contact:
Re: Player Character Name
I'd bet you could even use a function call, if the need arose. Oh, the possibilities...!monele wrote:Cool, I didn't expect a full python expression was possible ^_^
- PyTom
- Ren'Py Creator
- Posts: 16097
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Player Character Name
Yes, you can use any python expression, provided you quote it correctly.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
-
- Regular
- Posts: 87
- Joined: Sat Jun 23, 2007 9:19 am
- Projects: ALICE.NET
- Location: The other end of the internet.
- Contact:
Re: Player Character Name
But that's the fun part!PyTom wrote:Yes, you can use any python expression, provided you quote it correctly.
*still trying to think of uses for function calls in DynamicCharacter*
Who is online
Users browsing this forum: Directony, Google [Bot]