[SOLVED] Retaining side images

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
famakki1
Regular
Posts: 55
Joined: Wed Oct 12, 2016 7:40 am
Contact:

[SOLVED] Retaining side images

#1 Post by famakki1 »

Hi all,

In the example code below:

Code: Select all


# characters are defined as jack and jill

image jack_sprite = "jack.png"
image jill_sprite = "jill.png"

image side jack_face = "jack_face.png"
image jill = "jill_face.png"

label start:
    show jack_sprite at left
    jack jack_face "Hi Jill"
    show jill_sprite at right
    jill jill_face "Hi Jack"
    jack jack_face "Great weather we are having today."
    jill jill_face "Indeed."
    
It can be seen for side image usage, the side image has to be declared each time (from what I know). I want to know if it is possible for Ren'Py to automatically use the last used side image without defining it over and over. For example:

Code: Select all


# characters are defined as jack and jill

image jack_sprite = "jack.png"
image jill_sprite = "jill.png"

image side jack_face = "jack_face.png"
image jill = "jill_face.png"

label start:
    show jack_sprite at left
    jack jack_face "Hi Jill"
    show jill_sprite at right
    jill jill_face "Hi Jack"
    jack "Great weather we are having today." #jack side image not declared but I wish for it to  autoshow
    jill "Indeed." #same here. I wish to used the last declared side image without typing it in
    
So in this case, once jack_face and jill_face have been used, I want them to be show in every dialogue for Jack/Jill till I change it. Furthermore, if this is possible, I would like to know how to prevent side images to be shown in places where I don't wish to automatically populate with a side image (such as in novel mode).
Last edited by famakki1 on Thu Mar 23, 2017 1:51 am, edited 1 time in total.

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

Re: Retaining side images

#2 Post by Ocelot »

Make use of image tags and automatic image display:

Code: Select all

image jack sprite = "jack.png"
image jill sprite = "jill.png"

image side jack = "jack_face.png"
image side jill = "jill_face.png"

label start:
    show jack_sprite at left
    jack "Hi Jill"
    show jill_sprite at right
    jill "Hi Jack"
    jack "Great weather we are having today."
    jill "Indeed."
I would like to know how to prevent side images to be shown in places where I don't wish to automatically populate with a side image (such as in novel mode).
Default NVL screen does not show side images. If you create your own screen, it is easy to not show side images: just do not add them to your screen. (And if you want to show side images, you need to add displayable SideImage() to thst screen somewhere)
< < insert Rick Cook quote here > >

famakki1
Regular
Posts: 55
Joined: Wed Oct 12, 2016 7:40 am
Contact:

Re: Retaining side images

#3 Post by famakki1 »

Hi,

This does not seem to work for me... Perhaps it is because my side images contain underscores?

I noticed that underscores caused issues previously as well for me. I am defining for example:

image jack happy_big (close up)
image jack happy_small (far away)
Image side jack happy_face

I will test if removing underscores works but for now I want to somehow make big and small associate with face. Will test.

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

Re: Retaining side images

#4 Post by Ocelot »

First of all check if you linked image tag with a character. Like this define jack = Character("jack", image='jack')
And yes, underscores do matter. RenPy treats space separated names as series of tags. It then tries to show image with most matching tags as side image.
For example, in code you posted, first image has tags 'jack' and 'happy_big', side image has tags 'jack' and 'happy_face'. Only common tag is 'jack'. On the other hand, if you separate word with spaces, tags would be 'jack', 'happy', 'big' and 'jack', 'happy', 'face' respectively. Two tags in common.
Notice that if there are two images with the same amount of matching tags, then there is an ambiguity and no image is shown.
< < insert Rick Cook quote here > >

famakki1
Regular
Posts: 55
Joined: Wed Oct 12, 2016 7:40 am
Contact:

Re: [SOLVED] Retaining side images

#5 Post by famakki1 »

Hi Ocelot,

Thanks for your feedback and help so far ! I managed to get the auto-side image working. I followed your instructions and removed the underscores as a first step. It wasn't still working. Then I realized I had declared image tags as image = "Tony " instead of image = 'Tony'.

I think that extra space in the image tags prevented correct functionality, I was forced to do it previously due to underscores (eg. tony happy_big). But now I have defined all images as, eg. tony happy big , format. I am not sure if double quotes or apostrophe difference matters but for now I'll stick with the apostrophes to define image tag.

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

Re: [SOLVED] Retaining side images

#6 Post by Imperf3kt »

" is the same as ', but they can both be used for the same thing.

Sometimes, if you want to use " in a sentence, you need to use escapes in your script or you can just use the other quote.
For example, you have a line of dialogue, both of the following will display "Tony" saying Hi, I'm "Tony."

Code: Select all

Tony "Hi, I'm \"Tony.\""
Tony 'Hi, I'm "Tony."'
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

Post Reply

Who is online

Users browsing this forum: Dark79, Majestic-12 [Bot]