how does a player enter a name for the MC? [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
Cidz
Veteran
Posts: 458
Joined: Wed Jul 27, 2011 1:50 pm
Completed: The Forgetful Kiwi [NanoReno 2012], Papercut [NanoReno 2013]
Projects: Words Within Our Hearts, Papercut [NanoReno 2013]
Organization: Starlight Melodies
Tumblr: starlightmelodies
Deviantart: cidthekitty
Location: California, USA
Contact:

how does a player enter a name for the MC? [solved]

#1 Post by Cidz » Sat Dec 31, 2011 3:10 pm

I was wondering what the code is for a player to enter a name for the MC? i tried looking around the wiki, document, FAQs, and cookbook, but i didn't find anything. maybe I'm just not looking hard enough?

also how do i program it so that the name shows up every time either the MC speaks or someone calls the MC by their name.
Last edited by Cidz on Sun Jan 01, 2012 4:32 am, edited 3 times in total.

User avatar
Camille
Eileen-Class Veteran
Posts: 1226
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: Spirit Parade
Organization: Cyanide Tea
Tumblr: narihira
Deviantart: crownwaltz
Skype: thievinghearts
Contact:

Re: how does a player enter a name for the MC?

#2 Post by Camille » Sat Dec 31, 2011 3:33 pm

Here you go. There's more info on DynamicCharacter here on the wiki. And then every time you want the MC's name to show up, just do [namevariable]. If you're not using 6.13, then do %(namevariable)s.
1/2 of Cyanide Tea | Break Chance Memento (BL) | Spirit Parade (Otome) | Portfolio/List of Works/Contact
I'm not around LSF very much these days; please contact me via Skype/Twitter. Ask me things!

User avatar
Cidz
Veteran
Posts: 458
Joined: Wed Jul 27, 2011 1:50 pm
Completed: The Forgetful Kiwi [NanoReno 2012], Papercut [NanoReno 2013]
Projects: Words Within Our Hearts, Papercut [NanoReno 2013]
Organization: Starlight Melodies
Tumblr: starlightmelodies
Deviantart: cidthekitty
Location: California, USA
Contact:

Re: how does a player enter a name for the MC?

#3 Post by Cidz » Sat Dec 31, 2011 4:49 pm

thank you very much <3333

User avatar
Cidz
Veteran
Posts: 458
Joined: Wed Jul 27, 2011 1:50 pm
Completed: The Forgetful Kiwi [NanoReno 2012], Papercut [NanoReno 2013]
Projects: Words Within Our Hearts, Papercut [NanoReno 2013]
Organization: Starlight Melodies
Tumblr: starlightmelodies
Deviantart: cidthekitty
Location: California, USA
Contact:

Re: how does a player enter a name for the MC?

#4 Post by Cidz » Sat Dec 31, 2011 9:06 pm

i shouldnt of put solved so soon im running into a small problem.

how do i make the user chosen name appear like in the name box?

for example it shows up fine when a char says my name

Image

but when MC speaks it doesnt show up see

Image

the name code i used is this:

Code: Select all

# The phrase in the brackets is the text that the game will display to prompt 
# the player to enter the name they've chosen.

    $ player_name = renpy.input("Enter a name?")

    $ player_name = player_name.strip()
# The .strip() instruction removes any extra spaces the player 
# may have typed by accident.

#  If the player can't be bothered to choose a name, then we
#  choose a suitable one for them:
    if player_name == "":
        $ player_name=""

# And get a nostalgic sigh from Seasons of Sakura fans!
    
# Now the other characters in the game can greet the player.
and the code i used so that the name shows up when MC speaks is this

Code: Select all

define n = Character('%(player_name)s')
do i need to enter a different code for it to show?

User avatar
MoPark
Regular
Posts: 98
Joined: Sat Dec 31, 2011 7:05 pm
Projects: Kangaroo, Terminal Love
Location: DC
Contact:

Re: how does a player enter a name for the MC?

#5 Post by MoPark » Sat Dec 31, 2011 9:13 pm

It's not terribly difficult to implement. Here's an example from 6.10.2:

Code: Select all

init:
    $ povname = ""
    $ pov = DynamicCharacter("povname", color="#BF2A78")

$ povname = renpy.input("What is your name?") or "Alfred"
pov "I'm %(povname)s."
Last edited by MoPark on Sun Jan 01, 2012 2:10 am, edited 1 time in total.

User avatar
DragoonHP
Miko-Class Veteran
Posts: 734
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: how does a player enter a name for the MC?

#6 Post by DragoonHP » Sun Jan 01, 2012 12:57 am

@Cidz: Newer version of Ren'Py had some changes, one of them were changing the syntax of Ren'Py interpolation...

Try MoPark example but instead of this...

Code: Select all

pov "I'm %(povname)s."
use this

Code: Select all

pov "I'm [povname]."

User avatar
MoPark
Regular
Posts: 98
Joined: Sat Dec 31, 2011 7:05 pm
Projects: Kangaroo, Terminal Love
Location: DC
Contact:

Re: how does a player enter a name for the MC?

#7 Post by MoPark » Sun Jan 01, 2012 2:10 am

Okay I was dumb in my reply and forgot to include the first two lines under init:
My apologies!

User avatar
Cidz
Veteran
Posts: 458
Joined: Wed Jul 27, 2011 1:50 pm
Completed: The Forgetful Kiwi [NanoReno 2012], Papercut [NanoReno 2013]
Projects: Words Within Our Hearts, Papercut [NanoReno 2013]
Organization: Starlight Melodies
Tumblr: starlightmelodies
Deviantart: cidthekitty
Location: California, USA
Contact:

Re: how does a player enter a name for the MC?

#8 Post by Cidz » Sun Jan 01, 2012 2:37 am

@ MoPark and DragoonHP - Thank you! I will try that.

I don't have the newest version of renpy maybe I should try. I have version 6.12.1

User avatar
DragoonHP
Miko-Class Veteran
Posts: 734
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: how does a player enter a name for the MC?

#9 Post by DragoonHP » Sun Jan 01, 2012 3:13 am

I believe that it was already changed in Ren'Py 12

User avatar
Cidz
Veteran
Posts: 458
Joined: Wed Jul 27, 2011 1:50 pm
Completed: The Forgetful Kiwi [NanoReno 2012], Papercut [NanoReno 2013]
Projects: Words Within Our Hearts, Papercut [NanoReno 2013]
Organization: Starlight Melodies
Tumblr: starlightmelodies
Deviantart: cidthekitty
Location: California, USA
Contact:

Re: how does a player enter a name for the MC?

#10 Post by Cidz » Sun Jan 01, 2012 3:40 am

hmm... now im having another problem. i used the code and i made a seperate name file in renpy, tested it out. works great. So then i input it into my game script and now its giving me and error

Image

heres the code in my game.

Code: Select all

label start:   
    
init:
    $ povname = ""
    $ pov = DynamicCharacter("povname", color="#BF2A78")

    $ povname = renpy.input("What is your name?") or "Alfred"
    pov "I'm %(povname)s."
i even tried [povname] instead still nothing. sorry to be such a bother I'm just new to coding.

User avatar
Rewritten Ennui
Veteran
Posts: 279
Joined: Thu Jul 14, 2011 1:50 pm
Organization: TwinTurtle Games
Contact:

Re: how does a player enter a name for the MC?

#11 Post by Rewritten Ennui » Sun Jan 01, 2012 3:55 am

I'll just give you the code I'm using >_>
When defining characters, do it as so:

Code: Select all

define p = DynamicCharacter('player_name', color = "#58D3F7")
And in the script, allow the player to chose a name like this.

Code: Select all

$ player_name = renpy.input("What is your first name?", "Bobert", length=20)
    p"My name is[player_name]! Yayz~!"
This code will show a default name, and the player can delete it and input a name of their own if they want. Remember to always update to the latest version of Ren'Py, although I think this should work with the 6.12.1 version.
I've swapped accounts to CheeryMoya, so this account is no longer in use. Refer to the new account if you want to contact me.

Twinturtle Games Website

User avatar
Cidz
Veteran
Posts: 458
Joined: Wed Jul 27, 2011 1:50 pm
Completed: The Forgetful Kiwi [NanoReno 2012], Papercut [NanoReno 2013]
Projects: Words Within Our Hearts, Papercut [NanoReno 2013]
Organization: Starlight Melodies
Tumblr: starlightmelodies
Deviantart: cidthekitty
Location: California, USA
Contact:

Re: how does a player enter a name for the MC?

#12 Post by Cidz » Sun Jan 01, 2012 4:28 am

it works! perfectly! thank you so much!
also i updated renpy and now have the latest version.

thank you everyone for your help.

User avatar
DragoonHP
Miko-Class Veteran
Posts: 734
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: how does a player enter a name for the MC? [solved]

#13 Post by DragoonHP » Sun Jan 01, 2012 4:44 am

You had indentations problem in your code...

Code: Select all

label start:   
   
init:
    $ povname = " "
    $ pov = DynamicCharacter("povname", color="#BF2A78")

$ povname = renpy.input("What is your name?") or "Alfred"
pov "I'm [povname]."
This should work fine...

User avatar
Cidz
Veteran
Posts: 458
Joined: Wed Jul 27, 2011 1:50 pm
Completed: The Forgetful Kiwi [NanoReno 2012], Papercut [NanoReno 2013]
Projects: Words Within Our Hearts, Papercut [NanoReno 2013]
Organization: Starlight Melodies
Tumblr: starlightmelodies
Deviantart: cidthekitty
Location: California, USA
Contact:

Re: how does a player enter a name for the MC? [solved]

#14 Post by Cidz » Sun Jan 01, 2012 5:21 am

ah thank you <3 i figured it out now.

User avatar
eternalwishess
Regular
Posts: 77
Joined: Sat Jul 30, 2011 9:18 pm
Contact:

Re: how does a player enter a name for the MC? [solved]

#15 Post by eternalwishess » Wed Jan 04, 2012 2:52 am

I had that error a moment ago....im glad i found this before posting a new topic about the same problem. Thanks all ^__^
Call me αίкσ, hehe. C:

Post Reply

Who is online

Users browsing this forum: hell_oh_world