How to hide side images when not needed?

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
m4yuge
Newbie
Posts: 1
Joined: Fri Nov 11, 2011 9:34 pm
Contact:

How to hide side images when not needed?

#1 Post by m4yuge »

I use side images in this one game I'm making, but at certain parts of the game I'd rather not have them there (and just have the blank space on the left side of the text box). Can anyone help me with this? I've looked on the wiki and the manual but I haven't been able to find how to do this.

This is the code that I'm using at the moment to create side images:

Code: Select all

define a = DynamicCharacter("al_name", color="#52A3CC", image="alfred")
define e = Character("Arthur", color="#7AA300", image="arthur")
init python:
     style.window.left_padding = 180
And when I want to show a specific side image:

Code: Select all

    a happy "You're welcome! Haha."
But I want to be able to hide side images, too. Do I need to use a new code from the start altogether? I'd like to avoid that, as I already have a good portion of the game down.

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: How to hide side images when not needed?

#2 Post by PyTom »

You can make the call to SideImage in the screens conditional.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
pyopyon
Veteran
Posts: 451
Joined: Thu Aug 29, 2013 4:35 am
Completed: https://chouette.itch.io/
Projects: Ocean Pearls, Catching the Fox [NaNo16], Singles
Organization: Jellyfish Parade
Tumblr: jelpiparade
Skype: miss.chouette
Soundcloud: pyopyon
itch: chouette
Contact:

Re: How to hide side images when not needed?

#3 Post by pyopyon »

I never know whether it's better to revive an ancient topic from the depths or start a new one....

Anyway, there's nothing in the renpy documentation about calling onditional side images so I... must ask.

How is this done?
Image ImageImage

WiP: Image

✿ Writer for Trade/Commission ✿

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: How to hide side images when not needed?

#4 Post by xela »

As suggested by PyTom, you just add a condition to say screen and use it to control the side image. All of that is in the docs.
Like what we're doing? Support us at:
Image

User avatar
pyopyon
Veteran
Posts: 451
Joined: Thu Aug 29, 2013 4:35 am
Completed: https://chouette.itch.io/
Projects: Ocean Pearls, Catching the Fox [NaNo16], Singles
Organization: Jellyfish Parade
Tumblr: jelpiparade
Skype: miss.chouette
Soundcloud: pyopyon
itch: chouette
Contact:

Re: How to hide side images when not needed?

#5 Post by pyopyon »

Where in the docs? (Can I have a link because I didn't see it. .__.;; )
Image ImageImage

WiP: Image

✿ Writer for Trade/Commission ✿

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

Re: How to hide side images when not needed?

#6 Post by Ocelot »

There: https://www.renpy.org/doc/html/screens.html#if

Your say screen would look like that:

Code: Select all

# Other say screen code
if should_show_side_image:
    add SideImage()
< < insert Rick Cook quote here > >

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

Re: How to hide side images when not needed?

#7 Post by Imperf3kt »

An even easier way, if you cannot understand the above link, is just define a second character with the same name but no side image defined.

Code: Select all

define f = Character('Engelbert Humperdinck', image="engel")
image side engel = "engel.png"
define f2 = Character('Engelbert Humperdinck', image="None")

Code: Select all

f "I have a side image"
f2 "Huh, where'd it go?"
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
pyopyon
Veteran
Posts: 451
Joined: Thu Aug 29, 2013 4:35 am
Completed: https://chouette.itch.io/
Projects: Ocean Pearls, Catching the Fox [NaNo16], Singles
Organization: Jellyfish Parade
Tumblr: jelpiparade
Skype: miss.chouette
Soundcloud: pyopyon
itch: chouette
Contact:

Re: How to hide side images when not needed?

#8 Post by pyopyon »

Ocelot wrote:There: https://www.renpy.org/doc/html/screens.html#if

Your say screen would look like that:

Code: Select all

# Other say screen code
if should_show_side_image:
    add SideImage()
Looking at the screens link, I think I understand. Would using the above negate the use of config.side_image_tag = "image"?
Imperf3kt wrote:An even easier way, if you cannot understand the above link, is just define a second character with the same name but no side image defined.

Code: Select all

define f = Character('Engelbert Humperdinck', image="engel")
image side engel = "engel.png"
define f2 = Character('Engelbert Humperdinck', image="None")

Code: Select all

f "I have a side image"
f2 "Huh, where'd it go?"
Ah, I actually wanted to keep my MC's face there even when another character was talking, so I used config.side_image_tag = "image"... defining another person won't work, I think.
Image ImageImage

WiP: Image

✿ Writer for Trade/Commission ✿

zxcvbnm
Newbie
Posts: 3
Joined: Wed Nov 13, 2019 2:02 pm
Contact:

Re: How to hide side images when not needed?

#9 Post by zxcvbnm »

Hi! I know it's an old topic but I have just the same problem. I warn you in advance that I don't know programming at all and I am just starting with Renpy.

I wanted to bring and hide side image on my command so I typed:

Code: Select all

if should_show_side_image:
    add SideImage()
So now my screen say looks like this:

Code: Select all

screen say(who, what):
    style_prefix "say"

    window:
        id "window"

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                text who id "who"

        text what id "what"

    if not renpy.variant("small"):
        add SideImage() xalign 0.0 yalign 1.0
    if should_show_side_image:
        add SideImage()
But when I launch the game it crashes and in my traceback file i have this error:
File "game/screens.rpy", line 118, in execute
if should_show_side_image:
NameError: name 'should_show_side_image' is not defined
I know it's probably very dumb question but how can I define this should_show_side_image? Or maybe I made a mistake somewhere else?

User avatar
komehara
Regular
Posts: 36
Joined: Fri Jan 31, 2020 10:08 pm
Projects: Spirit Link
Tumblr: hsandt
Deviantart: hsandt
Github: hsandt
itch: komehara
Contact:

Re: How to hide side images when not needed?

#10 Post by komehara »

I defined it as default flag in script.rpy:

Code: Select all

# Visual flags

default should_show_side_image = False
In addition, I combined the extra flag with the variant check to avoid displaying the side image on non-small variant, when should_show_side_image is False:

Code: Select all

# screens.rpy
screen say(who, what):
	...
	## When you need to show side image, set should_show_side_image to True just the time you need it
	## It is defaulted to False in script.rpy
	if not renpy.variant("small") and should_show_side_image:
		add SideImage() xalign 0.0 yalign 1.0
Usage:

Code: Select all

$ should_show_side_image = True
a happy "You're welcome! Haha."
$ should_show_side_image = False

Post Reply

Who is online

Users browsing this forum: No registered users