Help With Hover displayText & Custom Char Names

Forum organization and occasional community-building.
Forum rules
Questions about Ren'Py should go in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
bDunks
Newbie
Posts: 21
Joined: Tue Jan 08, 2019 3:07 pm
Contact:

Help With Hover displayText & Custom Char Names

#1 Post by bDunks »

I have created custom names for characters & some hovers with the displayText.
hovered Show("displayTextScreen", displayText = "[m1_name]")

If I do this as shown above, it displays the name literally. [m1_name]
If I remove the quotes & brackets, it works.

However, it fails when using multiple words as well as 's.
hovered Show("displayTextScreen", displayText = m1_name's Car)

I have tried multiple things & I just can't get it to work.
If you can help, I would appreciate it.
Thank you for your time. :)

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Help With Hover displayText & Custom Char Names

#2 Post by Alex »

bDunks wrote: Thu Sep 08, 2022 7:36 am ...
"[m1_name]" - this is the Ren'Py-style data interpolation.
https://www.renpy.org/doc/html/text.htm ... ating-data

But in your case the python-style text formatting is required, so try it like

Code: Select all

# m1_name is the variable, so it doesn't need quotes
Show("displayTextScreen", displayText = m1_name)

Show("displayTextScreen", displayText = "{} - {}".format(m1_name, m2_name) )
Show("displayTextScreen", displayText = "{}'s Car".format(m1_name) )
Show("displayTextScreen", displayText = '{}\'s Car'.format(m1_name) )
https://docs.python.org/3/library/stri ... t-examples
https://www.renpy.org/doc/html/text.htm ... characters

bDunks
Newbie
Posts: 21
Joined: Tue Jan 08, 2019 3:07 pm
Contact:

Re: Help With Hover displayText & Custom Char Names

#3 Post by bDunks »

Alex

Thank you so much for answering my question. I never learned to code, only pick up bits & pieces here & there until I get some sort of Frankenstein of what I want to work, ha ha.

I used this one here:

Code: Select all

Show("displayTextScreen", displayText = "{}'s Car".format(m1_name) )
I was dismayed when it came back with an error.
Well, that's because I wondered if it should look like this:

Code: Select all

Show("displayTextScreen", displayText = "{m1_name}'s Car".format(m1_name) )
I tried it straight, the way you showed, & it worked!
Thanks again. Take care. :)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]