Player input uppercase/lowercase letters

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
kinkiepinkie
Newbie
Posts: 8
Joined: Wed Jan 02, 2019 6:25 pm
Contact:

Player input uppercase/lowercase letters

#1 Post by kinkiepinkie » Sat Feb 16, 2019 6:22 am

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?

User avatar
Remix
Eileen-Class Veteran
Posts: 1307
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Player input uppercase/lowercase letters

#2 Post by Remix » Sat Feb 16, 2019 8:00 am

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."
Mad Scientist Todo List:
  • Finish Improved Event Handler
  • Implement DragonBones animation as a Creator Defined Container
  • Develop Cartoon Speech Bubble dialogue
  • Finish Bitmask collision and rebound vector system
  • Develop time based building mechanic
  • Others
  • *Find a superb artist and actually write a game*

kinkiepinkie
Newbie
Posts: 8
Joined: Wed Jan 02, 2019 6:25 pm
Contact:

Re: Player input uppercase/lowercase letters

#3 Post by kinkiepinkie » Sat Feb 16, 2019 8:05 am

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.

User avatar
Remix
Eileen-Class Veteran
Posts: 1307
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Player input uppercase/lowercase letters

#4 Post by Remix » Sat Feb 16, 2019 8:36 am

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
Mad Scientist Todo List:
  • Finish Improved Event Handler
  • Implement DragonBones animation as a Creator Defined Container
  • Develop Cartoon Speech Bubble dialogue
  • Finish Bitmask collision and rebound vector system
  • Develop time based building mechanic
  • Others
  • *Find a superb artist and actually write a game*

kinkiepinkie
Newbie
Posts: 8
Joined: Wed Jan 02, 2019 6:25 pm
Contact:

Re: Player input uppercase/lowercase letters

#5 Post by kinkiepinkie » Sat Feb 16, 2019 8:56 am

Yes, I thought, teacher/Teacher were predefined variables.
Thank you very much. Sorry for that

Post Reply

Who is online

Users browsing this forum: No registered users