Character name as image

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
menostorpe
Newbie
Posts: 15
Joined: Tue Jan 06, 2009 10:01 am
Contact:

Character name as image

#1 Post by menostorpe »

I'd like to have my characters' names be displayed as images, not text. Exactly as is requested/explained in the first part of this thread:
viewtopic.php?f=8&t=6483

I feel like there must be a straightforward way to do this, as suggested there:
define ban = Character("names/mrbanner.png", show_image=True)
That no longer works, however. I assume it has been renamed again, or Ren'py has changed in some way that renders this method unusable? I have tried to search the documentation and tutorials and not found any that seem to address this directly.

User avatar
indoneko
Miko-Class Veteran
Posts: 528
Joined: Sat Sep 03, 2016 4:00 am
Contact:

Re: Character name as image

#2 Post by indoneko »

you might need to modify the say screen, so that it accepts namebox image
My avatar is courtesy of Mellanthe

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3809
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Character name as image

#3 Post by Imperf3kt »

There is an image in the gui called namebox.png, but when I tried to use it, nothing happened.

My suggestion is to just make it part of your side image and edit the mobile code to allow the side image (if you plan to release on Android or iOS)
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Character name as image

#4 Post by trooper6 »

Have you tried using the image text tag?
https://www.renpy.org/doc/html/text.html#text-tag-image
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

menostorpe
Newbie
Posts: 15
Joined: Tue Jan 06, 2009 10:01 am
Contact:

Re: Character name as image

#5 Post by menostorpe »

Thanks to everyone for their suggestions so far.
indoneko wrote:you might need to modify the say screen, so that it accepts namebox image
Looking at screens.rpy, I don't see anything that jumps out as me as a switch for this. Is there something I need to add? If so, could someone help me with what that might be?
Imperf3kt wrote:There is an image in the gui called namebox.png, but when I tried to use it, nothing happened.

My suggestion is to just make it part of your side image and edit the mobile code to allow the side image (if you plan to release on Android or iOS)
I'm perfectly willing to use any alternate methods. Maybe side images could be the way to do it, though I'll note that we're not actually using side images at all in this project. If the best way to do it is turn off the namebox and instead use side images as a namebox, that would be fine, but I'd need some help on where to begin with this since my initial tests didn't work so well.
trooper6 wrote:Have you tried using the image text tag?
https://www.renpy.org/doc/html/text.html#text-tag-image
That tag works fine, but places the image inline with the text (and we'd like it to be above the text box). If there is a way to position it properly, though, wouldn't it be needed on every single line of dialogue?

User avatar
indoneko
Miko-Class Veteran
Posts: 528
Joined: Sat Sep 03, 2016 4:00 am
Contact:

Re: Character name as image

#6 Post by indoneko »

@menostorpe : nevermind.... trooper6's suggestion is actually enough (and much simpler) for your requirement. You just need to add

who_ypos = n

where n is your target position

edit :
Here's an example of how you define your character :

define ban = Character("{image=names/mrbanner.png}", who_ypos=-50)

edit2 :
you also need to turn off default namebox frame in screens.rpy
just find this line on that file and add # sign in front of it :

background Frame("gui/namebox.png", gui.namebox_borders, tile=gui.namebox_tile, xalign=gui.name_xalign)
My avatar is courtesy of Mellanthe

menostorpe
Newbie
Posts: 15
Joined: Tue Jan 06, 2009 10:01 am
Contact:

Re: Character name as image

#7 Post by menostorpe »

Ah, sorry for misunderstanding your suggestion, trooper6. And thank you for your help, indoneko. I think I'm most of the way there now.

Defining the character as you stated worked, but it resulted in each line of text starting well below the top of the text box. I managed to fix that by adding what_ypos:
define ban = Character("{image=names/mrbanner.png}", who_ypos=-90, what_ypos=-70)
Is that a bad practice, or is there any reason I shouldn't do it that way? I have noticed that the number of lines for characters defined this way seems to change the size of the textbox, while other characters do not. That is, if a bit of dialogue is long enough to take up two lines on the screen, the textbox becomes one line taller. I assume this is because of the way I defined the character? Is there an alternative that would keep the textbox the same size?

User avatar
indoneko
Miko-Class Veteran
Posts: 528
Joined: Sat Sep 03, 2016 4:00 am
Contact:

Re: Character name as image

#8 Post by indoneko »

Adding what_ypos=n is normal practice. Did you modify something else on screens.rpy and gui.rpy?

Textbox height usually defined in this line in gui.rpy :

define gui.textbox_height = n

where n can be any integer (for fixed height), or None (for auto-fit box that can change size automatically)

If you still having trouble, perhaps you could copy-paste your script here (or post as attachment)
My avatar is courtesy of Mellanthe

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3809
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Character name as image

#9 Post by Imperf3kt »

You seem to have a solution, but just to follow-up, this is how you implement the alternative I suggested:

Script.rpy

Code: Select all

########################################
#####          Characters          #####

define ban = Character('', image="banname")

########################################
#####         Side Images          #####

image side banname = "ban.png"
And thats it. By default, the side image aligns bottom left, but you can change it's position within gui.rpy or simply make the image large enough that it reaches where you want it to.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

menostorpe
Newbie
Posts: 15
Joined: Tue Jan 06, 2009 10:01 am
Contact:

Re: Character name as image

#10 Post by menostorpe »

indoneko wrote:Adding what_ypos=n is normal practice. Did you modify something else on screens.rpy and gui.rpy?
Heh, yes. I've been working on this project for a few months, so I've fiddled with almost everything. I actually don't have a gui.rpy, I presume because I started this game in an older version? Thanks for confirming that's an acceptable method, though.

In options.rpy, I set style.window.yminimum and .ymaximum to the same value, which seems to keep the textbox at the size I want. Somebody stop me if that's a dumb method or there's something else I should be doing.

User avatar
senisanti
Regular
Posts: 94
Joined: Tue May 07, 2019 4:37 am
Projects: Allball, Smash scrap metal, Santi...
Location: Rennes
Contact:

Re: Character name as image

#11 Post by senisanti »

Hi.

I reopen this thread because today in 2023 none of the proposed solutions work, so I'd like to know how we can now put an image instead the name.

Thanks.

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Character name as image

#12 Post by _ticlock_ »

senisanti wrote: Sat Aug 05, 2023 6:00 am Hi.

I reopen this thread because today in 2023 none of the proposed solutions work, so I'd like to know how we can now put an image instead the name.

Thanks.
Both approaches work for me:

Code: Select all

define e = Character("", namebox_background="namebox2.png")
define e2 = Character("{image=namebox2.png}")

label start:
    e "check"
    e2 "check2"
You can post your code, so we can figure out what the problem is.

User avatar
senisanti
Regular
Posts: 94
Joined: Tue May 07, 2019 4:37 am
Projects: Allball, Smash scrap metal, Santi...
Location: Rennes
Contact:

Re: Character name as image

#13 Post by senisanti »

What format do you put the images in, what size, because I may not understand the original message very well, but I thought this message was to put a small image on the left side.

With the method given, the image is with the text and appears below the text.

User avatar
Andredron
Miko-Class Veteran
Posts: 738
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Character name as image

#14 Post by Andredron »

In your screens.rpy file, find the say screen. Replace it with this:

Code: Select all

screen say(who, what):
    style_prefix "say"
    window:
        id "window"
        
    if who is not None:
          window:
                id "namebox"
                style "namebox"
                image "[who]Name.png"

Now add all your namebox images to the "images" folder labelled as "<name>Name.png". For example, add "gavinName.png" to the "images" folder.

Now create your character normally.

define g = Character("gavin", color="#69df69")

Make sure the "gavin" in the Character constructor is the same as the <name> in the namebox image.

#############

Else - foreground:.

define g = Character(None, foreground = "images/gogi.png", color="#69df69")

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Ocelot