Page 1 of 1
[SOLVED] Display the first letters of the [MC] name?
Posted: Thu May 30, 2019 6:58 am
by liagel
Hello!
I would have a question about displaying the [MC]'s name.
In a dialogue between two characters, I would like one of them to say only the first letters of the name:
Example: [MC]'s name is Superman.
ch1 "What's his name?"
ch2 "His name is Sup... Clark! His name is Clark!"
So, I have made the usual to ask for [MC]'s name:
Code: Select all
define h = Character("[MC]", color="#ffffff")
(...)
label nameMC:
$ hero = renpy.input("What is your Name?", allow=" 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", length=10)
(...)
etc.
Now, how can I display the first two or three first letters of my MC?
If someone has an idea, I would be grateful
Re: Display the first letters of the [MC] name?
Posted: Thu May 30, 2019 9:04 am
by Per K Grok
liagel wrote: ↑Thu May 30, 2019 6:58 am
Hello!
I would have a question about displaying the [MC]'s name.
In a dialogue between two characters, I would like one of them to say only the first letters of the name:
Example: [MC]'s name is Superman.
ch1 "What's his name?"
ch2 "His name is Sup... Clark! His name is Clark!"
So, I have made the usual to ask for [MC]'s name:
Code: Select all
define h = Character("[MC]", color="#ffffff")
(...)
label nameMC:
$ hero = renpy.input("What is your Name?", allow=" 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", length=10)
(...)
etc.
Now, how can I display the first two or three first letters of my MC?
If someone has an idea, I would be grateful
You could do this,
Code: Select all
label nameMC:
$ hero = renpy.input("What is your Name?", allow=" 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", length=10)
$ shorthero= hero[:3]
e "Hello [shorthero]..."
Re: Display the first letters of the [MC] name?
Posted: Thu May 30, 2019 10:22 am
by Remix
For just truncating from the start (as pyformat does not support mid string truncation) you could (untested) just use:
Code: Select all
"The first 3 letters of your name are: [hero:.3]"
In the next release (or nightlies) you could also add !c or to force upper case first letter btw, "[hero:.3!c]"
Re: Display the first letters of the [MC] name?
Posted: Thu May 30, 2019 12:59 pm
by liagel
Remix wrote: ↑Thu May 30, 2019 10:22 am
For just truncating from the start (as pyformat does not support mid string truncation) you could (untested) just use:
Code: Select all
"The first 3 letters of your name are: [hero:.3]"
In the next release (or nightlies) you could also add !c or to force upper case first letter btw, "[hero:.3!c]"
Yes Remix! It works perfectly!
Code: Select all
ch "His name is [hero:.3]... Clark! His name is Clark."
gives : His name is
Sup... Clark! His name is Clark. (The uppercase is displayed.)
Thank you Remix and thank you Per K Grok.