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 »

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: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

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

#2 Post by Camille »

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.

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 »

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 »

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?

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 »

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.

DragoonHP
Miko-Class Veteran
Posts: 758
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 »

@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]."

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 »

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 »

@ 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

DragoonHP
Miko-Class Veteran
Posts: 758
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 »

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 »

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.

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 »

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 »

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

thank you everyone for your help.

DragoonHP
Miko-Class Veteran
Posts: 758
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 »

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 »

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 »

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: No registered users