Page 1 of 1

How to hide side images when not needed?

Posted: Fri Nov 11, 2011 9:43 pm
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.

Re: How to hide side images when not needed?

Posted: Sat Nov 12, 2011 12:17 am
by PyTom
You can make the call to SideImage in the screens conditional.

Re: How to hide side images when not needed?

Posted: Wed Feb 08, 2017 12:06 pm
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?

Re: How to hide side images when not needed?

Posted: Wed Feb 08, 2017 12:56 pm
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.

Re: How to hide side images when not needed?

Posted: Wed Feb 08, 2017 1:56 pm
by pyopyon
Where in the docs? (Can I have a link because I didn't see it. .__.;; )

Re: How to hide side images when not needed?

Posted: Wed Feb 08, 2017 2:00 pm
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()

Re: How to hide side images when not needed?

Posted: Wed Feb 08, 2017 2:23 pm
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?"

Re: How to hide side images when not needed?

Posted: Thu Feb 09, 2017 11:57 am
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.

Re: How to hide side images when not needed?

Posted: Wed Nov 13, 2019 2:30 pm
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?

Re: How to hide side images when not needed?

Posted: Mon Jul 03, 2023 2:23 pm
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