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
User avatar
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 » Fri Nov 11, 2011 9:43 pm

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: 15436
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 » Sat Nov 12, 2011 12:17 am

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
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
pyopyon
Veteran
Posts: 409
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 » Wed Feb 08, 2017 12:06 pm

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

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: 409
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 » Wed Feb 08, 2017 1:56 pm

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
Miko-Class Veteran
Posts: 849
Joined: Tue Aug 23, 2016 10:35 am
Skype: miinipaa
Contact:

Re: How to hide side images when not needed?

#6 Post by Ocelot » Wed Feb 08, 2017 2:00 pm

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: 2721
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: How to hide side images when not needed?

#7 Post by Imperf3kt » Wed Feb 08, 2017 2:23 pm

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.

Todo list:
Actually finish a project

User avatar
pyopyon
Veteran
Posts: 409
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 » Thu Feb 09, 2017 11:57 am

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 ✿

User avatar
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 » Wed Nov 13, 2019 2:30 pm

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?

Post Reply

Who is online

Users browsing this forum: Pandar, solarProtag