An interesting bug/quirk discovered for regular sprite updating where layeredimage conditionals are evaluated immediately. Thumbnail is a sourdough cinnamon roll.


Wrangling our production expression changing function into working correctly

The performance of RE:H in Ren’Py 6.x is really a non-issue, so we have started making some small updates, just enough to bring it to v7.3.2.

You might recall last week that we used the function renpy.show() to show the sprite again with an updated expression. We didn’t mention it last week, but this function will make the textbox/character name box blink every time you call it. This is undesirable behavior.

gif of bishop having easy dissolve expression change

Too easy.

Relevant code snippets for the above image:

python:
    def cexp(m):
        global mouth
        mouth = m
        renpy.show(Dissolve(.2,alpha=True))
    
label intro:
    show rexc 1
    e " HELLO"
    $ cexp("shout")
    e " ho SHOUTING"
    $ cexp("smile")

In a great bit of surprise, it was not at all difficult to update the layeredimage to have almost the correct behavior. Recall that our current expression changing implementation is

show rexc 1
    e " HELLO"
    $ epc("rex", "angry", "narrow", "shout")
    # show side rex_p brow_angry eyes_narrow mouth_shout with dissolve
    e " ho SHOUTING"
    $ epc("rex", "raised", "medium","smile")

The two snippets look very similar. There’s a single line to change expressions right before a line of dialogue. Now, the only problem is the blinking textbox.

[…]

After much digging around, we finally discovered that we didn’t actually want renpy.show()…the function we’re looking for is renpy.transition().

It was frustratingly difficult to find the second function.

    def cexp(m):
        global mouth
        mouth = m
        renpy.transition(Dissolve(.2,alpha=True), layer='master')

Markus loses his glasses

We define Markus with a layeredimage like so:

    layeredimage markus 1:
        at Transform(xalign=.5, xoffset=100, ypos=750, maxsize=(600,750))   
        #             ), size=(320,569))

        always "images/sprites/Markus/markus1_upper.png"    
        always "images/sprites/Markus/markus1_[markus_head].png"
        always "images/sprites/Markus/markus1_[markus_arms].png" 
        always "images/sprites/Markus/markus1_[markus_head]_eyes_[markus_eyes].png" 
        always "images/sprites/Markus/markus1_[markus_head]_brow_[markus_brow].png" 
        always "images/sprites/Markus/markus1_[markus_head]_mouth_[markus_mouth].png" 

        if markus_glasses:
            "images/sprites/Markus/markus1_[markus_head]_sunglasses.png" 

This definition allows the dissolve transition in the corrected epc() function to work properly. However, there is a conditional for whether Markus is wearing his sunglasses. Unfortunately, even though the transition can apply to changing all the expressions (arms, head, eyes, etc.), the conditional is evaluated as soon as it is set, before the transition can be applied. As a result, you get…

Zoom.

It’s actually easier to see the problem when you are making a gif screen recording of a video…the delay/compression is being helpful this time!

Freedom, at last!

What’s the solution to this? Find out on our next episode of Upgrading to 7.3.2!

(Solution is still TBD. But there are some Ideas.)