Expression Not Working Properly

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
Zelan
Lemma-Class Veteran
Posts: 2436
Joined: Tue Mar 01, 2016 7:23 pm
Completed: The Dark
Projects: Cosplay Couple
Tumblr: evns
itch: Zelan
Discord: ltnkitsuragi#7082
Contact:

Expression Not Working Properly

#1 Post by Zelan »

I know how to code expressions (or I thought I did) but for some reason my sprite's normal/neutral expression isn't showing up the second time I use it. It works fine the first time, and the second time doesn't look any different to me, so I don't understand what the problem is.

Here's my code:

Code: Select all

define c = Character("Camryn")
image couch = "gaycouch.jpg"
image angry = "Angry-Annoyed.png"
image blush = "Blushing smile.png"
image normal = "Calm.png"
image sad = "Concerned-Doubtful.png"
image confused = "Confused.png"
image big smile blush = "Laughing Blush.png"
image big smile = "Laughing.png"
image happy = "Smile.png"



# The game starts here.

label start:

    scene couch
    show big smile
    c "Hello! It's so nice to meet you!"
    show normal
    c "My name is Camryn and I use they/them pronouns."
    c "I'm here to teach you about trans history!"
    show sad
    c "As of right now, it's something that isn't taught often in schools."
    c "Even in higher education like college, most people don't learn queer history except in specialized classes. It's something I'd like to change."
    show happy
    c "But until then, there are resources out there! And I'm here to help you find them."
    show normal
    c "Consider this a crash course in trans history. We'll only be scratching the surface here."
    c "What would you like to learn about?"
    # This ends the game.

    return
The first time I use "show normal" it works fine, but the second time it continued to display the "happy" expression. I tried changing the order of "show normal" and "show happy" just to see if it would work, and it just continued to show the "sad" expression.

User avatar
Jackkel Dragon
Veteran
Posts: 283
Joined: Mon Mar 31, 2014 7:17 pm
Organization: Nightshade, Team Despair
itch: jackkel-dragon
Location: USA
Contact:

Re: Expression Not Working Properly

#2 Post by Jackkel Dragon »

Going off the code I see here, I think the problem is that your statements are creating a bunch of separate images, so the automatic hiding of related images isn't working.

Your code:

Code: Select all

image big smile = "Laughing.png" ## define the image "big" with sub-image "smile"
image big smile blush = "Laughing Blush.png" ## define the image "big" with sub-image "smile" with sub-image "blush"
image normal = "Calm.png" ## define the image "normal"

show big smile ## show "big" with attribute "smile"
c "Hello! It's so nice to meet you!"
show normal ## show "normal"
This means that both "big" and "normal" are displayed at the same time, with "normal" closest to the screen.

Visual fix of your code:

Code: Select all

show big smile ## show "big" with attribute "smile"
c "Hello! It's so nice to meet you!"
hide big ## hide "big"
show normal ## show "normal"
This fixes the problem from a player perspective, but requires a LOT of extraneous code to create

Ren'Py expressions/attributes fix:

Code: Select all

image camryn big_smile = "Laughing.png" ## define the image "camryn" with sub-image "big_smile"
image camryn big_smile_blush = "Laughing Blush.png" ## define the image "camryn" with sub-image "big_smile_blush"
image camryn normal = "Calm.png" ## define the image "camryn" with sub-image "normal"

show camryn big_smile ## show "camryn" with attribute "big_smile"
c "Hello! It's so nice to meet you!"
show camryn normal ## show "camryn" with attribute "normal", hiding "camryn big_smile"
There are also other ways to make defining the images easier, but this is the basic way of using Ren'Py's automatic system for swapping out images.

Hopefully that helps... I feel like it may have gotten a bit technical.
Main Website
Includes information about and links to many of my current and past projects.

Major Game Projects
[Nightshade] Eldritch Academy, Eldritch University, Blooming Nightshade, Flowering Nightshade, Life as Designed
[Team Despair] Corpse Party D2 series

User avatar
Zelan
Lemma-Class Veteran
Posts: 2436
Joined: Tue Mar 01, 2016 7:23 pm
Completed: The Dark
Projects: Cosplay Couple
Tumblr: evns
itch: Zelan
Discord: ltnkitsuragi#7082
Contact:

Re: Expression Not Working Properly

#3 Post by Zelan »

Jackkel Dragon wrote: Sat May 16, 2020 5:18 pm Going off the code I see here, I think the problem is that your statements are creating a bunch of separate images, so the automatic hiding of related images isn't working.

Your code:

Code: Select all

image big smile = "Laughing.png" ## define the image "big" with sub-image "smile"
image big smile blush = "Laughing Blush.png" ## define the image "big" with sub-image "smile" with sub-image "blush"
image normal = "Calm.png" ## define the image "normal"

show big smile ## show "big" with attribute "smile"
c "Hello! It's so nice to meet you!"
show normal ## show "normal"
This means that both "big" and "normal" are displayed at the same time, with "normal" closest to the screen.

Visual fix of your code:

Code: Select all

show big smile ## show "big" with attribute "smile"
c "Hello! It's so nice to meet you!"
hide big ## hide "big"
show normal ## show "normal"
This fixes the problem from a player perspective, but requires a LOT of extraneous code to create

Ren'Py expressions/attributes fix:

Code: Select all

image camryn big_smile = "Laughing.png" ## define the image "camryn" with sub-image "big_smile"
image camryn big_smile_blush = "Laughing Blush.png" ## define the image "camryn" with sub-image "big_smile_blush"
image camryn normal = "Calm.png" ## define the image "camryn" with sub-image "normal"

show camryn big_smile ## show "camryn" with attribute "big_smile"
c "Hello! It's so nice to meet you!"
show camryn normal ## show "camryn" with attribute "normal", hiding "camryn big_smile"
There are also other ways to make defining the images easier, but this is the basic way of using Ren'Py's automatic system for swapping out images.

Hopefully that helps... I feel like it may have gotten a bit technical.
LMAO, I knew it would be something small like this. I figured I could skip defining the character since I only have one, should have known it would cause me problems. Thanks so much for your help!

User avatar
Milkymalk
Miko-Class Veteran
Posts: 756
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Expression Not Working Properly

#4 Post by Milkymalk »

What you skipped is not defining the character, but giving the images the same tag. The first part of an image's name is the tag by which Renpy determines if a newly shown image should replace another. It works exactly the same as the "tag" keyword for screens in that regard.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot]