[Solved] How to get the name of the player in the dialog box?

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
Trafagal
Regular
Posts: 100
Joined: Mon Apr 29, 2019 9:32 am
Contact:

[Solved] How to get the name of the player in the dialog box?

#1 Post by Trafagal »

Hi,

So in my game I allow the player to input the name of his using the code below:

Code: Select all

    # This starts the input for the player's name.
    $ name = renpy.input("What is your name?")
    $ name = name.strip()
    
    if name == "":
       $ name="Jonathan"
  
    "You can create anything in this world. Pleased to meet you, [name]!"
    # This ends the input of player's name.
So let's say I key in "Jack", as long as there is [name]. The name will appear.

But how do I get the name appear in the name of the dialog box?
Attachments
q.JPG
Last edited by Trafagal on Tue May 26, 2020 9:04 pm, edited 1 time in total.
Check out some of my stuffs here:https://linktr.ee/theartofjoshlab

Art Portfolio: https://www.instagram.com/theartofjoshlab/

Working on a personal Visual Novel~

User avatar
iDweadith
Regular
Posts: 63
Joined: Sun Mar 01, 2020 4:15 pm
Contact:

Re: How to get the name of the player in the dialog box?

#2 Post by iDweadith »

Code: Select all

define pov = Character("[povname]")

python:
    povname = renpy.input("What is your name?")
    povname = povname.strip()

    if not povname:
         povname = "Pat Smith"

pov "My name is [povname]!"

User avatar
Trafagal
Regular
Posts: 100
Joined: Mon Apr 29, 2019 9:32 am
Contact:

Re: How to get the name of the player in the dialog box?

#3 Post by Trafagal »

iDweadith wrote: Tue May 26, 2020 6:14 am

Code: Select all

define pov = Character("[povname]")

python:
    povname = renpy.input("What is your name?")
    povname = povname.strip()

    if not povname:
         povname = "Pat Smith"

pov "My name is [povname]!"
Thank you iDweadith! Do i put this in scrypt.renpy itself?
Check out some of my stuffs here:https://linktr.ee/theartofjoshlab

Art Portfolio: https://www.instagram.com/theartofjoshlab/

Working on a personal Visual Novel~

User avatar
iDweadith
Regular
Posts: 63
Joined: Sun Mar 01, 2020 4:15 pm
Contact:

Re: How to get the name of the player in the dialog box?

#4 Post by iDweadith »

Yes, in script.rpy like this

Code: Select all

define pov = Character("[povname]")

label start:

    python:
        povname = renpy.input("What is your name?")
        povname = povname.strip()

        if not povname:
             povname = "Pat Smith"

    pov "My name is [povname]!"

User avatar
Trafagal
Regular
Posts: 100
Joined: Mon Apr 29, 2019 9:32 am
Contact:

Re: How to get the name of the player in the dialog box?

#5 Post by Trafagal »

Thanks! It works, I realize I just need to add the define statement.

define name = Character("[name]")

Thank you so much!
Check out some of my stuffs here:https://linktr.ee/theartofjoshlab

Art Portfolio: https://www.instagram.com/theartofjoshlab/

Working on a personal Visual Novel~

Post Reply

Who is online

Users browsing this forum: Nozori_Games