Choosing players name questions.

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
DeletedUser160413

Choosing players name questions.

#1 Post by DeletedUser160413 » Fri Nov 08, 2013 11:02 am

Players name: Whenever I choose a name with the letter 'S', the save page comes up. I know its a quick button so I dont want to remove it because players may want to use it, so how do I remove it from when I'm writing the name?

And also there is only a choose name field, but I want to use both first and last names in this game! In work MC is going to be called after her last name, and privately its gonna be her first name, so how do I do this?

Tsapas
Regular
Posts: 69
Joined: Mon Oct 14, 2013 8:18 am
Contact:

Re: Choosing players name questions.

#2 Post by Tsapas » Fri Nov 08, 2013 11:22 am

Are you typing the name via renpy.input? It shouldn't trigger the save screen at all.

Also for name separation you can try this:

Code: Select all

$ povName = renpy.input("What is your name?", length=50) or "Default full name if none entered"
python:
    if " " in povName:  #checks there is space char in name, indicating a full name.
        povFirstName,povLastName = povName.split(" ")
or

Code: Select all

$ povFirstName = renpy.input("What is your first name?", length=15) or "default name"
$ povLastName = renpy.input("What is your last name?", length=30) or "default surname"
$ povName = povFirstName +" "+povLastName
Whichever suits you best.
This way you can have [povName] for the full MC name, [povFirstName] for his name and [povLastName] for his surname.

DeletedUser160413

Re: Choosing players name questions.

#3 Post by DeletedUser160413 » Fri Nov 08, 2013 11:29 am

Tsapas wrote:Are you typing the name via renpy.input? It shouldn't trigger the save screen at all.

Also for name separation you can try this:

Code: Select all

$ povName = renpy.input("What is your name?", length=50) or "Default name if none entered"
python:
    if " " in povName:#checks if trigger is persistent or not.
        povFirstName,povLastName = povName.split(" ")
This way you can have [povName] for the full MC name, [povFirstName] for his name and [povLastName] for his surname.

Omg, perfect. This is what I wanted. But I'm a little confused of where everything should be, sorry :/

Here is what I wrote in the script:

"What's your name?"

# 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("What is your 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="Me"


# And get a nostalgic sigh from Seasons of Sakura fans!

# Now the other characters in the game can greet the player.
"All right, let us start the game, %(player_name)s!"


######################################


It also says in renpy's wiki that player_name might become too difficult to write out everytime. So where exactly do I change it to something like me or m? And btw what if I made the choose name screen obligatory, as in you must choose a name or you cant really go on with the game?

Tsapas
Regular
Posts: 69
Joined: Mon Oct 14, 2013 8:18 am
Contact:

Re: Choosing players name questions.

#4 Post by Tsapas » Fri Nov 08, 2013 11:37 am

muniiam wrote: Omg, perfect. This is what I wanted. But I'm a little confused of where everything should be, sorry :/

Here is what I wrote in the script:
You can do this

Code: Select all

 "What's your name?"

 # 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("What is your name?") or "Me" #check for no input in name is done here
 $ player_name = player_name.strip() # it may interfere with the splitting code if it strips space chars mid-string, need to check on that. If it's a problem use .rstrip() instead.

 python:
     if " " in player_name:
         player_first_name,player_last_name = player_name.split(" ") # If no full name is provided (no space chars), the [player_first_name] and [player_last_name] will remain blank.

 # And get a nostalgic sigh from Seasons of Sakura fans!
    
 # Now the other characters in the game can greet the player.
 "All right, let us start the game, [player_name]!"
You also need to define those at start, so it won't produce an error

Code: Select all

define player_first_name = ""
define player_last_name = ""
define player_name = ""   
I've also updated my previous post, to correct some wrongly pasted comments and also show another way.
It also says in renpy's wiki that player_name might become too difficult to write out everytime. So where exactly do I change it to something like me or m? And btw what if I made the choose name screen obligatory, as in you must choose a name or you cant really go on with the game?
Well, if it gets to a default name if the player doesn't type in one, I don't see why you should make it obligatory ;), just let the player decide.

DeletedUser160413

Re: Choosing players name questions.

#5 Post by DeletedUser160413 » Fri Nov 08, 2013 12:55 pm

Tsapas wrote:
muniiam wrote: Omg, perfect. This is what I wanted. But I'm a little confused of where everything should be, sorry :/

Here is what I wrote in the script:
You can do this

Code: Select all

 "What's your name?"

 # 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("What is your name?") or "Me" #check for no input in name is done here
 $ player_name = player_name.strip() # it may interfere with the splitting code if it strips space chars mid-string, need to check on that. If it's a problem use .rstrip() instead.

 python:
     if " " in player_name:
         player_first_name,player_last_name = player_name.split(" ") # If no full name is provided (no space chars), the [player_first_name] and [player_last_name] will remain blank.

 # And get a nostalgic sigh from Seasons of Sakura fans!
    
 # Now the other characters in the game can greet the player.
 "All right, let us start the game, [player_name]!"
You also need to define those at start, so it won't produce an error

Code: Select all

define player_first_name = ""
define player_last_name = ""
define player_name = ""   
I've also updated my previous post, to correct some wrongly pasted comments and also show another way.
It also says in renpy's wiki that player_name might become too difficult to write out everytime. So where exactly do I change it to something like me or m? And btw what if I made the choose name screen obligatory, as in you must choose a name or you cant really go on with the game?
Well, if it gets to a default name if the player doesn't type in one, I don't see why you should make it obligatory ;), just let the player decide.
LOL I can't come up with a default name xD

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Choosing players name questions.

#6 Post by PyTom » Sun Nov 10, 2013 3:28 pm

muniiam wrote:LOL I can't come up with a default name xD
Hiro Protagonist.

(Although, that name was used for the main character of Snow Crash.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Deadpool209977
Newbie
Posts: 7
Joined: Sun Dec 26, 2021 3:29 pm
Completed: Experimental Life Intro
Projects: Experimental Life: Training
Organization: BenCo Studios
Contact:

Re: Choosing players name questions.

#7 Post by Deadpool209977 » Sun Dec 26, 2021 3:50 pm

I don't get how to set the character to have a default name and still have the rename options.
I posted a script shot to show what I did. Any help for this noob would be appreciated.

Oh! All the "name" slots are confusing.

$ povFirstName = renpy.input("What is your first name?", length=15) or "default name"
or is it supposed to be
$ povFirstName = renpy.input("What is your first name?", length=15) or "Bill"

Where default name is Bill as the main character in the story.

Also how do you sent up the "declare character" for this? I'm so lost LOL!

My Script

# Declare characters used by this game.
define = Character("Bill Johnson")
define v = Character("Vicky")
define s = Character(Sarah")
define j = Character("John")


# Define Images.


# The game starts here.

label start:

$ povFirstName = renpy.input("What is your first name?", length=15) or "default name"
$ povLastName = renpy.input("What is your last name?", length=30) or "default surname"
$ povName = povFirstName +" "+povLastName



NM got it. Just didn't understand to start with.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], _ticlock_