Change character name dynamically[SOLVED!]

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
Yuuji
Regular
Posts: 96
Joined: Tue Jan 20, 2015 3:08 am
Location: Russia, Perm
Contact:

Change character name dynamically[SOLVED!]

#1 Post by Yuuji »

Hello! I want to use in my game 2 names transcription systems: polivanov and hepburn and I want to allow user change it in game's preferences. So, I want to be able change character name. Is there a way to implement that? I'd appreciate any help.
Last edited by Yuuji on Sat Jan 24, 2015 8:36 pm, edited 1 time in total.
There's no point in standing around with your mouth open waiting for talent to fall from the sky. You make your own. No matter what you're doing, the most essential thing is not to give up.

philat
Eileen-Class Veteran
Posts: 1926
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Change character name dynamically

#2 Post by philat »

Code: Select all

init:
    variable = "Name"
    define c = Character([variable])

User avatar
Yuuji
Regular
Posts: 96
Joined: Tue Jan 20, 2015 3:08 am
Location: Russia, Perm
Contact:

Re: Change character name dynamically

#3 Post by Yuuji »

And with this code when I change variable, character object will change either? I thought when I define character, object is created and variable is copying to this object. Or not?
There's no point in standing around with your mouth open waiting for talent to fall from the sky. You make your own. No matter what you're doing, the most essential thing is not to give up.

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: Change character name dynamically

#4 Post by trooper6 »

As Philat writes, using interpolation is the way to do it.

In my game I organize it like so:

Code: Select all

define b = Character('[barb_name]', color="#994411", what_color="#FFFFCC", 
    what_slow_cps=20, what_slow_abortable=False)
define c = Character('[cust_name]', color="#99FF66", what_color="#FFFFCC")

label start:    
    
    #variables
    $ cust_name = "Customer"
    $ barb_name = "Barber"

    b "{=narr}(Rising at once--)\n{/=narr}{fast}Good afternoon, sir." #Barber Friendly
    c "My good man, it that clock right?" #Customer C1 Concerned

    $ barb_name = "Thomas"

    b "Call me Thomas, if you like, sir."
   
    $ cust_name = "Smitty"
    c "Well then, Thomas, you may call me Smitty."
This code works in my game and the documentation is here:
http://www.renpy.org/doc/html/text.html ... ating-data

I put the name variable after the start label because someone on here told me that it is better to put all variables right after the start label...apparently this has something to do with saving.

Hope that helps.
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
Yuuji
Regular
Posts: 96
Joined: Tue Jan 20, 2015 3:08 am
Location: Russia, Perm
Contact:

Re: Change character name dynamically

#5 Post by Yuuji »

Thank you very much!
There's no point in standing around with your mouth open waiting for talent to fall from the sky. You make your own. No matter what you're doing, the most essential thing is not to give up.

Post Reply

Who is online

Users browsing this forum: Google [Bot]