Page 1 of 1

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

Posted: Sat Dec 31, 2011 3:10 pm
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.

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

Posted: Sat Dec 31, 2011 3:33 pm
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.

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

Posted: Sat Dec 31, 2011 4:49 pm
by Cidz
thank you very much <3333

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

Posted: Sat Dec 31, 2011 9:06 pm
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?

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

Posted: Sat Dec 31, 2011 9:13 pm
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."

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

Posted: Sun Jan 01, 2012 12:57 am
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]."

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

Posted: Sun Jan 01, 2012 2:10 am
by MoPark
Okay I was dumb in my reply and forgot to include the first two lines under init:
My apologies!

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

Posted: Sun Jan 01, 2012 2:37 am
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

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

Posted: Sun Jan 01, 2012 3:13 am
by DragoonHP
I believe that it was already changed in Ren'Py 12

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

Posted: Sun Jan 01, 2012 3:40 am
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.

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

Posted: Sun Jan 01, 2012 3:55 am
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.

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

Posted: Sun Jan 01, 2012 4:28 am
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.

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

Posted: Sun Jan 01, 2012 4:44 am
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...

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

Posted: Sun Jan 01, 2012 5:21 am
by Cidz
ah thank you <3 i figured it out now.

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

Posted: Wed Jan 04, 2012 2:52 am
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 ^__^