[SOLVED] Display the first letters of the [MC] name?

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
liagel
Regular
Posts: 28
Joined: Thu Jan 10, 2019 5:13 pm
Contact:

[SOLVED] Display the first letters of the [MC] name?

#1 Post by liagel » 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 :)
Last edited by liagel on Thu May 30, 2019 12:59 pm, edited 1 time in total.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 630
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1
Projects: Defenders of Adacan Part 2
Deviantart: pekj
itch: per-k-grok
Location: Sverige
Contact:

Re: Display the first letters of the [MC] name?

#2 Post by Per K Grok » Thu May 30, 2019 9:04 am

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]..."
Image Visual Story Telling, DeviantArt Group for animations, comics, games and illustrations https://www.deviantart.com/acgi

User avatar
Remix
Eileen-Class Veteran
Posts: 1375
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: Display the first letters of the [MC] name?

#3 Post by Remix » 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]"
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*

liagel
Regular
Posts: 28
Joined: Thu Jan 10, 2019 5:13 pm
Contact:

Re: Display the first letters of the [MC] name?

#4 Post by liagel » Thu May 30, 2019 12:59 pm

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. :D

Post Reply

Who is online

Users browsing this forum: No registered users