Need help with Transition Condition Switch.

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
Dark79
Regular
Posts: 63
Joined: Sun Apr 18, 2021 2:21 pm
Contact:

Need help with Transition Condition Switch.

#1 Post by Dark79 »

Hi all.

Since I just cannot figure out how to use layeredimage the way i want to for example when I want to change expression, each expression change would have a transition effect (dissolve).
I tried to use Asceai's code for TransitionConditionSwitch viewtopic.php?f=51&t=26612#p326683. This does have a transition effect which I wish I could have something like that in layerimages(i just like the design :D ).

But I now get and error when using TransitionConditionSwitch within LiveComposite, called:

Code: Select all

File "game/characters.rpy", line 152, in per_interact
    if change_to is not self.current_d:
UnboundLocalError: local variable 'change_to' referenced before assignment
I am not so good with OOP but I understand the issue is with "change_to".

User avatar
piinkpuddiin
Newbie
Posts: 5
Joined: Sat Dec 16, 2023 3:20 pm
Completed: Rotten Wife, Priscyllia's last night, The Succubus Won't Fuck Me
Projects: "You're so nice!", TBD, TTGH
Tumblr: piinkpuddiin
itch: piinkpuddiin
Contact:

Re: Need help with Transition Condition Switch.

#2 Post by piinkpuddiin »

Hi, not sure I can be of much help as I'm not that good with OOP too :oops: but LiveComposite has been deprecated for a while, try Composite.
https://www.renpy.org/doc/html/changelog6.html#changes

User avatar
Dark79
Regular
Posts: 63
Joined: Sun Apr 18, 2021 2:21 pm
Contact:

Re: Need help with Transition Condition Switch.

#3 Post by Dark79 »

piinkpuddiin wrote: Fri Mar 22, 2024 10:48 am Hi, not sure I can be of much help as I'm not that good with OOP too :oops: but LiveComposite has been deprecated for a while, try Composite.
https://www.renpy.org/doc/html/changelog6.html#changes
I tried to use Composite but I am still getting same error. i assume in the past it worked well, but now there have been many updates for Ren'py and python 3.xx so something has changed.

I know layeredimages do take ATL and you can apply ATL for every expression like this:

Code: Select all

layeredimage person:
   
    always:
        "body.png"
      
    group eyes prefix "eyes":
        attribute open:
            "/eyes_open.png" at RandomATL
        
        attribute closed:
            "eyes_closed.png" at RandomATL
            
But I can't mimic like this a proper dissolve effect. :|.

Ofcourse I can put dissolve effect like this:

Code: Select all

show person
with dissolve #or renpy.transition(dissolve, layer="master") #Applies transition only to images that are in master layer.
 
Problem with this is that transition will be applied to the whole image where i want only for the expression to have the transition effect. (Not pleasing when you want to move the image while applying at the same time the transition dissolve, it looks weird when the image is moving.

jeffster
Veteran
Posts: 409
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Need help with Transition Condition Switch.

#4 Post by jeffster »

Dark79 wrote: Fri Mar 22, 2024 12:18 am Since I just cannot figure out how to use layeredimage the way i want to for example when I want to change expression, each expression change would have a transition effect (dissolve).
It's probably like changing any other image, "with dissolve":

Code: Select all

    show augustina
    aug "I like this dress."

    show augustina happy
    with dissolve
https://renpy.org/doc/html/layeredimage.html
But I now get and error when using TransitionConditionSwitch within LiveComposite, called:

Code: Select all

File "game/characters.rpy", line 152, in per_interact
    if change_to is not self.current_d:
UnboundLocalError: local variable 'change_to' referenced before assignment
The error message says that when that line was executed, variable change_to was not defined.
Perhaps that error wouldn't happen if you insert at the very beginning of that function:

change_to = None

Like this:

Code: Select all

        def per_interact(self):
            change_to = None

jeffster
Veteran
Posts: 409
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Need help with Transition Condition Switch.

#5 Post by jeffster »

Dark79 wrote: Sat Mar 23, 2024 10:36 pm But I can't mimic like this a proper dissolve effect. :|.
Why not?
https://renpy.org/doc/html/atl.html#atl-transitions

User avatar
Dark79
Regular
Posts: 63
Joined: Sun Apr 18, 2021 2:21 pm
Contact:

Re: Need help with Transition Condition Switch.

#6 Post by Dark79 »

jeffster wrote: Sun Mar 24, 2024 12:13 am
Dark79 wrote: Fri Mar 22, 2024 12:18 am Since I just cannot figure out how to use layeredimage the way i want to for example when I want to change expression, each expression change would have a transition effect (dissolve).
It's probably like changing any other image, "with dissolve":

Code: Select all

    show augustina
    aug "I like this dress."

    show augustina happy
    with dissolve
https://renpy.org/doc/html/layeredimage.html
But I now get and error when using TransitionConditionSwitch within LiveComposite, called:

Code: Select all

File "game/characters.rpy", line 152, in per_interact
    if change_to is not self.current_d:
UnboundLocalError: local variable 'change_to' referenced before assignment
The error message says that when that line was executed, variable change_to was not defined.
Perhaps that error wouldn't happen if you insert at the very beginning of that function:

change_to = None

Like this:

Code: Select all

        def per_interact(self):
            change_to = None

I tried that and i get this:

Code: Select all

File "game/characters.rpy", line 177, in per_interact
    self.ta = anim.TransitionAnimation(self.old_d, 0.00, self.transition, self.current_d)
Exception: Not a displayable: None
i also tried to put it like this.

Code: Select all

def per_interact(self):
    change_to = self.current_d
While this does not give any errors but changing expressions does not work it just stuck at one expression. Thanks for the suggestion by the way.

User avatar
Dark79
Regular
Posts: 63
Joined: Sun Apr 18, 2021 2:21 pm
Contact:

Re: Need help with Transition Condition Switch.

#7 Post by Dark79 »

jeffster wrote: Sun Mar 24, 2024 12:33 am
Dark79 wrote: Sat Mar 23, 2024 10:36 pm But I can't mimic like this a proper dissolve effect. :|.
Why not?
https://renpy.org/doc/html/atl.html#atl-transitions
I that was the last thing I tried before posting on the forums. I dunno maybe I am using it wrong way. I know that you use the ATL transition like normal transitions

Code: Select all

show person
with custom_atl_transition
But I am not sure how to use the transform ATL transition within layered image and I would rather use layerimage since its nicely organized, just sadly I can't figure out how to apply transitions when changing expressions.

User avatar
piinkpuddiin
Newbie
Posts: 5
Joined: Sat Dec 16, 2023 3:20 pm
Completed: Rotten Wife, Priscyllia's last night, The Succubus Won't Fuck Me
Projects: "You're so nice!", TBD, TTGH
Tumblr: piinkpuddiin
itch: piinkpuddiin
Contact:

Re: Need help with Transition Condition Switch.

#8 Post by piinkpuddiin »

I managed to give each expression an alpha dissolve but it is jarring as the face expression disappear completely and the next expression slowly appears. Hope this is somewhat helpful.

Code: Select all

transform persona_appear:
    on show:
        alpha 0.0
        linear 1.5 alpha 1.0
    on hide:
        linear .5 alpha 0.0

transform show_up:
    alpha 0.0
    linear 1.5 alpha 1.0


layeredimage smiler:
    at persona_appear

    always:
        "smiley_base.png"

    group face_reacts:
        
        attribute smile default at show_up:
            "smiley_def.png"

        attribute surprised at show_up:
            "smiley_surprise.png"

Code: Select all

label start:
    show beige_bg
    show smiler 

    sm "I am smiling."

    show smiler surprised

    sm "But I get easily surprised!"

    show smiler smile

    sm "But I always manage to smile through it!"

    hide smiler

    sm "That's it."

User avatar
Dark79
Regular
Posts: 63
Joined: Sun Apr 18, 2021 2:21 pm
Contact:

Re: Need help with Transition Condition Switch.

#9 Post by Dark79 »

piinkpuddiin wrote: Sun Mar 24, 2024 4:51 pm I managed to give each expression an alpha dissolve but it is jarring as the face expression disappear completely and the next expression slowly appears. Hope this is somewhat helpful.

Code: Select all

transform persona_appear:
    on show:
        alpha 0.0
        linear 1.5 alpha 1.0
    on hide:
        linear .5 alpha 0.0

transform show_up:
    alpha 0.0
    linear 1.5 alpha 1.0


layeredimage smiler:
    at persona_appear

    always:
        "smiley_base.png"

    group face_reacts:
        
        attribute smile default at show_up:
            "smiley_def.png"

        attribute surprised at show_up:
            "smiley_surprise.png"

Code: Select all

label start:
    show beige_bg
    show smiler 

    sm "I am smiling."

    show smiler surprised

    sm "But I get easily surprised!"

    show smiler smile

    sm "But I always manage to smile through it!"

    hide smiler

    sm "That's it."
Thanks for the help, while this is not exactly like a proper dissolve effect but it's a start, I tried to use on "persona_appear" transform on the expression but this does not take any effect" like "on show" and "on hide" do not work. I also tried to use "persona_appear" in IF condition in layeredimage and see if that will give any different effect but nope, just instant appearing image expressions. Still thank you:)

jeffster
Veteran
Posts: 409
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Need help with Transition Condition Switch.

#10 Post by jeffster »

As parts of layered image you can use images defined with ATL. You can apply transforms to those layer images, not affecting other layers. Example (try the attached script with files):

Code: Select all

# Animated transition from sad to happy
image sad2happy:
    "s2h_15.png"
    pause 0.06
    "s2h_14.png"
    pause 0.06
    "s2h_13.png"
    pause 0.06
    "s2h_12.png"
    pause 0.06
    "s2h_11.png"
    pause 0.06
    "s2h_10.png"
    pause 0.06
    "s2h_09.png"
    pause 0.06
    "s2h_08.png"
    pause 0.06
    "s2h_07.png"
    pause 0.06
    "s2h_06.png"
    pause 0.06
    "s2h_05.png"
    pause 0.06
    "s2h_04.png"
    pause 0.06
    "s2h_03.png"
    pause 0.06
    "s2h_02.png"
    pause 0.06
    "s2h_01.png"

# Animated transition from happy to sad
image happy2sad:
    "s2h_01.png"
    pause 0.06
    "s2h_02.png"
    pause 0.06
    "s2h_03.png"
    pause 0.06
    "s2h_04.png"
    pause 0.06
    "s2h_05.png"
    pause 0.06
    "s2h_06.png"
    pause 0.06
    "s2h_07.png"
    pause 0.06
    "s2h_08.png"
    pause 0.06
    "s2h_09.png"
    pause 0.06
    "s2h_10.png"
    pause 0.06
    "s2h_11.png"
    pause 0.06
    "s2h_12.png"
    pause 0.06
    "s2h_13.png"
    pause 0.06
    "s2h_14.png"
    pause 0.06
    "s2h_15.png"

layeredimage augustina:
    always:
        "bg.jpg"

    attribute sad2happy:
        "sad2happy"
        align (0.65, 0.45)
        xysize (400, 600)

    attribute happy2sad:
        "happy2sad"
        align (0.65, 0.45)
        xysize (400, 600)

label start:
    scene augustina

    "I'm neutral. Now I'm going to go from sad to happy"
    show augustina sad2happy

    "I'm happy. Now I'm going to be sad"
    show augustina happy2sad

    "I'm sad. Now I'll switch to neutral"
    jump start
You can use just a few frames for every transition, 0.2 sec is usually sufficient.
Attachments
layered_animation.zip
(374.62 KiB) Downloaded 3 times

jeffster
Veteran
Posts: 409
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Need help with Transition Condition Switch.

#11 Post by jeffster »

Dark79 wrote: Fri Mar 22, 2024 12:18 am I want to change expression, each expression change would have a transition effect (dissolve).
Try this:

Code: Select all

layeredimage augustina:
    always:
        "bg.jpg"

    attribute happy:
        "s2h_01.png"
        align (0.65, 0.45)
        xysize (400, 600)

    attribute sad:
        "s2h_15.png"
        align (0.65, 0.45)
        xysize (400, 600)

label start:
    scene augustina
    pause 1.0

    show augustina happy
    with dissolve
    pause 1.0

    show augustina -happy sad
    with dissolve
    pause 1.0

    show augustina -sad happy
    with dissolve
    pause 1.0
    "OK"

User avatar
Dark79
Regular
Posts: 63
Joined: Sun Apr 18, 2021 2:21 pm
Contact:

Re: Need help with Transition Condition Switch.

#12 Post by Dark79 »

jeffster wrote: Mon Mar 25, 2024 7:58 am
Dark79 wrote: Fri Mar 22, 2024 12:18 am I want to change expression, each expression change would have a transition effect (dissolve).
Try this:

Code: Select all

layeredimage augustina:
    always:
        "bg.jpg"

    attribute happy:
        "s2h_01.png"
        align (0.65, 0.45)
        xysize (400, 600)

    attribute sad:
        "s2h_15.png"
        align (0.65, 0.45)
        xysize (400, 600)

label start:
    scene augustina
    pause 1.0

    show augustina happy
    with dissolve
    pause 1.0

    show augustina -happy sad
    with dissolve
    pause 1.0

    show augustina -sad happy
    with dissolve
    pause 1.0
    "OK"
   


Thanks jeffster for the idea to use several images to achieve dissolve effect so I noted it down.

I don't prefer use "with dissolve" and if there is a lot of dialogue and a lot of changing expressions at the same time. I realised that using $ renpy.transition(dissolve, layer="master") instead "with dissolve" With this, it will apply the transition to the shown image at the same time while showing the new dialogue, instead of waiting for the image to finish it's transition and then the dialogue appears.

Code: Select all

layeredimage augustina:
    always:
        "bg.jpg"

    attribute happy:
        "s2h_01.png"
        align (0.65, 0.45)
        xysize (400, 600)

    attribute sad:
        "s2h_15.png"
        align (0.65, 0.45)
        xysize (400, 600)

label start:

    show augustina happy
    $ renpy.transition(dissolve, layer="master")
    "Dialogue 1"

    show augustina -happy sad
    $ renpy.transition(dissolve, layer="master")
     "Dialogue 2"

    show augustina -sad happy
    $ renpy.transition(dissolve, layer="master")
     "Dialogue 2"
   
Ofcourse its a bit on the eye to see and type "$ renpy.transition(dissolve, layer="master")" all the time but it's the closest thing to TransitionConditionalSwitch to achieve similar effect so I will settle with this.

Thanks everyone for the help I greatly appreciate it. :D

User avatar
Dark79
Regular
Posts: 63
Joined: Sun Apr 18, 2021 2:21 pm
Contact:

Re: Need help with Transition Condition Switch.

#13 Post by Dark79 »

deleted
Last edited by Dark79 on Tue Mar 26, 2024 4:47 am, edited 1 time in total.

User avatar
Dark79
Regular
Posts: 63
Joined: Sun Apr 18, 2021 2:21 pm
Contact:

Re: Need help with Transition Condition Switch.

#14 Post by Dark79 »

deleted

Post Reply

Who is online

Users browsing this forum: Google [Bot], munni