Page 1 of 1

Player input uppercase/lowercase letters

Posted: Sat Feb 16, 2019 6:22 am
by kinkiepinkie
Hello. I want to include a player input, where it will not be a name, actually, so it must be in lower case. But if I start the sentence with this word - the first letter should be capitalized automatically. Is it doable?
Let's say, this word is 'teacher'.
So, player input this word, and then I use it like that:

"I am your teacher."

But then, if I start the sentence with this word - it should be like that:

"Teacher's orders."

After a little search, I realized that I will have to define two cases. [teacher] and [Teacher]
Is it correct?

Re: Player input uppercase/lowercase letters

Posted: Sat Feb 16, 2019 8:00 am
by Remix
As variable names are case sensitive, you could just add an Upper case version and do something like:

Code: Select all

default pi_word = "teacher"
default Pi_word = "Teacher"

label start:

    $ pi_word = renpy.input("Type Word").strip().lower()
    $ Pi_word = pi_word.capitalize()

    "So, you typed [pi_word]. [Pi_word] is ok."

Re: Player input uppercase/lowercase letters

Posted: Sat Feb 16, 2019 8:05 am
by kinkiepinkie
Thanks, but I don't know what a player will input, so 'teacher' is just a guess.
I would like to use it for player input word.

Re: Player input uppercase/lowercase letters

Posted: Sat Feb 16, 2019 8:36 am
by Remix
So, rather than try it and see it does exactly what you asked, you decided instead to presume it doesn't work and ignore it?

teacher/Teacher are just defaults for the two variables
(you Must set them no matter what method you use)

It then asks for input...
It trims and lowercases that for the lowercase variable
It Capitalizes that for the uppercase variable

Just try it

Re: Player input uppercase/lowercase letters

Posted: Sat Feb 16, 2019 8:56 am
by kinkiepinkie
Yes, I thought, teacher/Teacher were predefined variables.
Thank you very much. Sorry for that