Condition switch Side image trouble

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
serusk
Newbie
Posts: 13
Joined: Sun May 15, 2011 1:33 pm
Projects: Aywen, Dorchadas
Contact:

Condition switch Side image trouble

#1 Post by serusk » Mon Aug 08, 2011 5:10 pm

I've been trying to do this, and because no one answered my question I've messing around alot.

So I thought this would help, but it doesn't work.

Code: Select all

define pcNormal = Character("povname",color="#000000", window_left_padding=160,
            show_side_image=ConditionSwitch(
                "skin == 'pale'", Image("PC female/pale.png", xalign=0.0, yalign=1.0),
                "skin == 'tan'", Image("PC female/tan.png", xalign=0.0, yalign=1.0),
                "emo == 'normal", Image("PC female/face normal.png", xalign=0.0, yalign=1.0)
                "hair == 'long", Image("PC female/face normal.png", xalign=0.0, yalign=1.0)
,
What i want it to do is the base is can be Pale or tan, so I also want different hair, but when i put the code for "$ hair = long", it doesn't change a thing.

what am I doing wrong?

User avatar
SleepKirby
Veteran
Posts: 255
Joined: Mon Aug 09, 2010 10:02 pm
Projects: Eastern Starlight Romance, Touhou Mecha
Organization: Dai-Sukima Dan
Location: California, USA
Contact:

Re: Condition switch Side image trouble

#2 Post by SleepKirby » Mon Aug 08, 2011 7:00 pm

A ConditionSwitch can only give you one image. It sounds like you're going to have a composition of two images: one for the base, and one for the hair. In this case, you'll need not just one ConditionSwitch, but two. Then you'll probably want to combine the ConditionSwitches into one image with im.Composite.

Code: Select all

show_side_image=im.Composite(
    (300, 600)
    (0, 0),
    ConditionSwitch(
        "skin == 'pale'", Image("PC female/skin pale.png", xalign=0.0, yalign=1.0),
        "skin == 'tan'", Image("PC female/skin tan.png", xalign=0.0, yalign=1.0)
        ),
    (0, 0),
    ConditionSwitch(
        "hair == 'normal'", Image("PC female/hair normal.png", xalign=0.0, yalign=1.0),
        "hair == 'long'", Image("PC female/hair long.png", xalign=0.0, yalign=1.0)
        )
)
(300, 600) specifies the width and height of the im.Composite "container" that holds all of the individual images. You should change this to fit your images. The first (0, 0) is the x,y position of the first image within this container, and the second (0, 0) is the x,y position of the second image.

(Once you've done all that, that should take care of the image positioning already, so I don't think you have to specify xalign and yalign within Image() - but anyway, you can play around with it.)

Post Reply

Who is online

Users browsing this forum: proller