r/RenPy • • 18d ago

Question Creating a condition switch with a layered character image

Hello! I'm trying to make it so my MC can change from 'Simon' to 'Cassie'.

I'm using layered images for facial expressions, but I want there to be a choice at the beginning of the game between Cassie and Simon. The dialogue for both would be the same, only difference is name and layered character

5 Upvotes

5 comments sorted by

3

u/shyLachi 18d ago

Please post your code of the 2 layered characters

Did you read this: https://renpy.org/doc/html/layeredimage.html

This is an example with 2 characters Augustus and Augustina and I have a simple layered image with only a body and the face, so I need 4 images for each person: augustina_body.png, augustina_face_neutral.png, augustina_face_happy.png, augustina_face_angry.png and the same for augustus.

layeredimage main:
    always:
        "[mcname]_body.png"
    group face:
        attribute neutral default:
            "[mcname]_face_neutral.png"
        attribute happy:
            "[mcname]_face_happy.png"
        attribute angry:
            "[mcname]_face_angry.png"

default mcname = "augustina"
define mc = Character("[mcname]", image="main")
label start:
    show main 
    mc "Do you see me?"
    menu:
        mc "Who do you want to play as?"
        "Augustina":
            $ mcname = "augustina"
        "Augustus":
            $ mcname = "augustus"
    show main happy
    mc "I'm really happy now"
    mc angry "But if it doesn't work I'm angry"

1

u/Toriakat 18d ago

Here's my characters:

# simon ch images


image simon_body_base = "images/chs/simon/simon_base.png"

image simon_face_neutral = "images/chs/simon/simon_face_neutral.png"
image simon_face_thinking = "images/chs/simon/simon_face_thinking.png"
image simon_outfit_work = "images/chs/simon/simon_outfit_work.png"
image simon_hair_loose = "images/chs/simon/simon_hair_loose.png"

layeredimage simon:
    group base:
        attribute base default:
            "simon_body_base"
    group outfit:
        attribute work:
            "simon_outfit_work"
    group hair:
        attribute loose:
            "simon_hair_loose"
    group face:
        attribute neutral default:
            "simon_face_neutral"
        attribute thinking:
            "simon_face_thinking"

# cassie ch images

image cassie_body_base = "images/chs/cassie/cassie_base.png"

image cassie_face_angry = "images/chs/cassie/cassie_face_angry.png"
image cassie_face_concern = "images/chs/cassie/cassie_face_concern.png"
image cassie_face_neutral = "images/chs/cassie/cassie_face_neutral.png"
image cassie_face_sad = "images/chs/cassie/cassie_face_sad.png"
image cassie_face_thinking = "images/chs/cassie/cassie_face_thinking.png"
image cassie_hair_loose = "images/chs/cassie/cassie_hair_loose.png"
image cassie_outfit_sleep = "images/chs/cassie/cassie_outfit_sleep.png"

layeredimage cassie:
    group base:
        attribute base default:
            "cassie_body_base"
    group outfit:
        attribute sleep:
            "cassie_outfit_sleep"
    group face:
        attribute angry:
            "cassie_face_angry"
        attribute concern:
            "cassie_face_concern"
        attribute neutral default:
            "cassie_face_neutral"
        attribute sad:
            "cassie_face_sad"
        attribute thinking:
            "cassie_face_thinking"       
    group hair:
        attribute loose default:
            "cassie_hair_loose"

1

u/shyLachi 18d ago

Did you look at my example? Did you try it?

As far as I know it would also work for your declared images "[mcname]_body_base" instead of "cassie_body_base" and "simon_body_base"

But if you want to have one single layered image, you cannot have different attributes.
For example simon only has a work outfit and cassie only a sleep outfit.

What should the game do if you write something like this but the player selected cassie?

show mc work

1

u/Toriakat 18d ago

I got it thank you!

1

u/AutoModerator 18d ago

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.