Question about checking names...?

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.
Message
Author
Mewmew
Newbie
Posts: 7
Joined: Mon Apr 23, 2007 12:53 am
Contact:

Question about checking names...?

#1 Post by Mewmew »

Hiya, I'm not used to the programming language... or programming in general, so I'll try my best to ask the question.

I was wondering if there was a way to check the name that the user has inputted. I don't really want anyone to input a blank name, though it's highly unlikely that someone would do that, it's still a possibility, and that would make my project look really weird. :o

This is what I currently have...

I'd like it to use the default name (Hiro) when someone decides to place in a blank name...

Code: Select all

$ hironame = renpy.input("Please input your name, and then press the 'Enter' key to continue.", "Hiro", length=10)
Name Imput Screen..
Image

When the user inputs a blank name...
Image

Thank you in advance... I must apologize for asking such a "newbie" question, but this has been bugging me for a while-- ^^;
世界の真実の光は誰か!
anime human, anthro, animal arts ♥
ledah.deviantart.com

monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

#2 Post by monele »

Just after asking for the name :

Code: Select all

if hironame == '':
    $ hironame = 'Hiro'
That's it :D

Mewmew
Newbie
Posts: 7
Joined: Mon Apr 23, 2007 12:53 am
Contact:

#3 Post by Mewmew »

Thank you so much! It works perfectly---
When I was trying to figure it out on my own, I kept placing double quotes instead... :oops: thanks again
世界の真実の光は誰か!
anime human, anthro, animal arts ♥
ledah.deviantart.com

monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

#4 Post by monele »

Mm;.. I don't think double quotes would change anything actually... Should work too :)

Mewmew
Newbie
Posts: 7
Joined: Mon Apr 23, 2007 12:53 am
Contact:

#5 Post by Mewmew »

Really? Hmm... I wonder what I have overlooked...
Oh! I think I had a double equal sign on the

Code: Select all

$ hironame = 'Hiro'
instead of just one... which... caused everything to fall apart XD :shock: Yay, I'm slowly learning ^^
世界の真実の光は誰か!
anime human, anthro, animal arts ♥
ledah.deviantart.com

monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

#6 Post by monele »

Ohh, ya, I see ^^. Just remember :

= means assignation (something will now be something else)
== means testing equality and is turned into "True" or "False"

Usual programming trap ^^

ChXris
Newbie
Posts: 12
Joined: Fri Mar 09, 2007 12:18 pm
Location: Chile
Contact:

#7 Post by ChXris »

= means assignation (something will now be something else)
== means testing equality and is turned into "True" or "False"
Great! Now i finally know the meaning of those things :D.


I want to use this topic to ask, how do put an input name in the game?
I dont think i should make another topic for this basic question :D
-Skills-
██████████ Writing
████████ Ideas
████ Speed
█████ Art design
████ Motivation
███ Codes

-Work in progress-
Game name: "Master server Ran de Lanour" (beta name)
In: Stage 1 - Focusing on codes and writing
Idea [80%]
Script [20%]
Art [0%]

monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

#8 Post by monele »

Just look at the code mewmew gave in the first post ô_o... the one with 'renpy.input'.

ChXris
Newbie
Posts: 12
Joined: Fri Mar 09, 2007 12:18 pm
Location: Chile
Contact:

#9 Post by ChXris »

And what do i do if i want to refer to the name in a dialog?

For example:
"You need to find (the input name)"
-Skills-
██████████ Writing
████████ Ideas
████ Speed
█████ Art design
████ Motivation
███ Codes

-Work in progress-
Game name: "Master server Ran de Lanour" (beta name)
In: Stage 1 - Focusing on codes and writing
Idea [80%]
Script [20%]
Art [0%]

Enerccio
Miko-Class Veteran
Posts: 616
Joined: Thu Oct 26, 2006 4:23 pm
Projects: My Teacher; Songs of Araiah; Something new; Possible Cross Bomber?
Location: Slovakia, Kosice
Contact:

#10 Post by Enerccio »

Code: Select all

"You need to find %(name)s"
where name is variable
:wink:
Image
http://www.bishojo.tk is technically ONLINE!
Songs of Araiah promo: http://www.youtube.com/watch?v=CalchucuoDU

ChXris
Newbie
Posts: 12
Joined: Fri Mar 09, 2007 12:18 pm
Location: Chile
Contact:

#11 Post by ChXris »

yay!

Thanks :D

Ill use it in my game... :wink:
-Skills-
██████████ Writing
████████ Ideas
████ Speed
█████ Art design
████ Motivation
███ Codes

-Work in progress-
Game name: "Master server Ran de Lanour" (beta name)
In: Stage 1 - Focusing on codes and writing
Idea [80%]
Script [20%]
Art [0%]

Enerccio
Miko-Class Veteran
Posts: 616
Joined: Thu Oct 26, 2006 4:23 pm
Projects: My Teacher; Songs of Araiah; Something new; Possible Cross Bomber?
Location: Slovakia, Kosice
Contact:

#12 Post by Enerccio »

your welcome ^^
Image
http://www.bishojo.tk is technically ONLINE!
Songs of Araiah promo: http://www.youtube.com/watch?v=CalchucuoDU

Baka Chikara
Regular
Posts: 39
Joined: Tue May 22, 2007 7:09 pm
Projects: Chill, Addendum
Location: Little Rock, Arkansas
Contact:

#13 Post by Baka Chikara »

I have a question about this. I was actually just searching for something like this, and it helps a lot. But...

I was wondering how you could change that variable name so that when it showed in the dialog box, it was a certain color I picked. Just like you can do with a regularly character name. When I did as the thread says, the name was always white. I guess I missing something?

(btw, I really like all the different Higurashi pics in your siggy, Enerccio)
Red: Together...!!
Blue: ...we are...!!
Yellow: ...the Prism Rangers!!
[All three pose together. Lights flash in the background.]
Laharl: ...Please, someone normal come out.

Enerccio
Miko-Class Veteran
Posts: 616
Joined: Thu Oct 26, 2006 4:23 pm
Projects: My Teacher; Songs of Araiah; Something new; Possible Cross Bomber?
Location: Slovakia, Kosice
Contact:

#14 Post by Enerccio »

Baka Chikara wrote:I have a question about this. I was actually just searching for something like this, and it helps a lot. But...

I was wondering how you could change that variable name so that when it showed in the dialog box, it was a certain color I picked. Just like you can do with a regularly character name. When I did as the thread says, the name was always white. I guess I missing something?

(btw, I really like all the different Higurashi pics in your siggy, Enerccio)
have you tried

Code: Select all

"You need to find {color=#444444}%(name)s{/color}"
I am not sure, since I never used it myself..

(Thanks, I will add more gifs since 2. series are really near ^^)
Image
http://www.bishojo.tk is technically ONLINE!
Songs of Araiah promo: http://www.youtube.com/watch?v=CalchucuoDU

Baka Chikara
Regular
Posts: 39
Joined: Tue May 22, 2007 7:09 pm
Projects: Chill, Addendum
Location: Little Rock, Arkansas
Contact:

#15 Post by Baka Chikara »

Well, I really wanted it to change the color of the name that appears in the top-left of the message box. Like, when you use the name the player put in as a character talking.

Ummmmmmm, screenshot!

Image
Red: Together...!!
Blue: ...we are...!!
Yellow: ...the Prism Rangers!!
[All three pose together. Lights flash in the background.]
Laharl: ...Please, someone normal come out.

Post Reply

Who is online

Users browsing this forum: henne