This page is out of date

You've reached a page on the Ren'Py wiki. Due to massive spam, the wiki hasn't been updated in over 5 years, and much of the information here is very out of date. We've kept it because some of it is of historic interest, but all the information relevant to modern versions of Ren'Py has been moved elsewhere.

Some places to look are:

Please do not create new links to this page.


ShowingSwitch

This chooses a displayable to show based on which images are being shown on the screen. It expects an even number of positional arguments. Odd positional arguments are expected to be image names, while even positional arguments are expected to be displayables. An image matches if it is the prefix of a shown image. If the image name is None, it always matches. It is an error if no match occurs.

This takes the keyword argument layer, which specifies the layer that will be checked to see if the images appear on it, defaulting to "master". Other keyword arguments are used to position the chosen displayable.

Shown image names are tracked by the predictive image loading mechanism, and so ShowingSwitch will properly predictively load images.

Example

init:
    $ e = Character(
        'Eileen',
        color="#c8ffc8",
        window_left_padding=160,
        show_side_image=ShowingSwitch(
            "eileen happy", "eileen_side_happy.png",
            "eileen vhappy", "eileen_side_vhappy.png",
            "eileen concerned", "eileen_side_concerned.png",            
            None, Null(),
            xalign=0.0, yalign=1.0))

Since the ShowingSwitch matches on the prefix of a shown image, you can "trick" it into thinking a particular image is displayed using null versions of images.

init:
    image eileen happy hidden = Null()
    image eileen concerned hidden = Null()

Then if Eileen's not visible but you want her side image to show a particular expression when she speaks, you can use code like this:

show eileen concerned hidden
e "Are you sure that's a good idea?"
"Oh! I didn't realise Eileen was there."
show eileen concerned