I can't get Character("bob", image="misc_picture") to show an image when speaking.

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
henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

I can't get Character("bob", image="misc_picture") to show an image when speaking.

#1 Post by henvu50 »

Here's my code:

Code: Select all

image testimage = "folder/test.jpg"
define npc = Character("npcguy", image="testimage")

label any:
    npc "Hello, you can see my name npcguy, but you can't see the image associated with my character object."
The expected result is that the testimage is shown somewhere, anywhere on the screen, right?

The example here is confusing: https://www.renpy.org/doc/html/dialogue ... attributes

Why even bother associating an image with character if you still need to use show anyways, doesn't that defeat the purpose of even specifying something in the image= part of the character object?

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2402
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: I can't get Character("bob", image="misc_picture") to show an image when speaking.

#2 Post by Ocelot »

It is there to streamline image display. As most show statement are used just to change expression of already displayed character, baking it within say statement makes code more clear:

Code: Select all

image testimage neutral = "folder/test.jpg"
image testimage bored = "folder/test-bored.jpg"
image testimage annoyed = "folder/test-annoyed.jpg"
define npc = Character("npcguy", image="testimage")

# . . .
show testimage neutral
npc "Right now the neutral image is showing..."
npc bored "... and now I am bored. At least I didn't have to write 'show testimage bored' before this statement..."
npc @ annoyed "... this saves me from writing 'show testimage annoyed' before and 'show testimage bored' after this statement..."
npc annoyed @ neutral "and this saves me from writing "'show testimage neutral'/'show testimage annoyed' before/after this statement"
npc "I am still annoyed there." 
Compare to code with show:

Code: Select all

# . . .
show testimage neutral
npc "..."
show testimage bored
npc "..."
show testimage annoyed
npc "..."
show testimage bored # If there are transitions defined, both those statements could have an effect
show testimage neutral
npc "..."
show testimage annoyed
npc "..." 
Another use of linking image, is allowing use of side images: https://www.renpy.org/doc/html/side_image.html
< < insert Rick Cook quote here > >

henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: I can't get Character("bob", image="misc_picture") to show an image when speaking.

#3 Post by henvu50 »

Oh, I see. There's more to it. That's a great feature, thanks.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]