Conditionswitch and transitions [SOLVED]

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
Badriel
Regular
Posts: 66
Joined: Mon Jul 23, 2012 1:10 pm
Completed: Clockwork City
Tumblr: badrielart
Deviantart: badriel
Contact:

Conditionswitch and transitions [SOLVED]

#1 Post by Badriel »

Hello, I'm wondering if it's possible to enable transitions or one-time animations when using conditionswitch. I know I can make repeated loop, but one-time animation doesn't work. Basically, I want to use layered sprites, but whenever I change a function for expressions, the change is very abrupt.

The code I'm using is:

Code: Select all

image Girl = ConditionSwitch(
            "e_face == 'angry'", LiveComposite(
                (566, 800),
                (0, 0), "body.png",
                (0, 0), "angry face.png",
                ),
            "e_face == 'cheeky'", LiveComposite(
                (566, 800),
                (0, 0), "body.png",
                (0, 0), "cheeky face.png",
                ),
            "e_face == 'None'", "body.png")
And then:

Code: Select all

   show girl with dissolve
    $ e_face = "angry"
    "test"
    $ e_face = "cheeky"
How could I achieve a smooth transition between these two? I tried making the face image into something like:

Code: Select all

image face_angry:
    "angry face.png"
    alpha 0.0
    linear .5 alpha 1.0
And inserting it into the Livecomposite inside the Conditionswitch. But it doesn't work. If I added repeat at the end of the transform, it'd work, but without it, the transform doesn't happen. (Or, actually, happens, in the very moment I launch the game, even before the sprite appears, so it looks as if it didn't happen).


TL;DR: How to get transitions when using Conditionswitch?
Last edited by Badriel on Fri Sep 06, 2013 3:45 am, edited 1 time in total.

User avatar
Greeny
Miko-Class Veteran
Posts: 921
Joined: Sun Dec 20, 2009 10:15 am
Completed: The Loop, The Madness
Projects: In Orbit, TBA
Organization: Gliese Productions
Location: Cantankerous Castle
Contact:

Re: Conditionswitch and transitions

#2 Post by Greeny »

I think it's not possible, not within ConditionSwitch. You'll need to find some kind of workaround...

I didn't try this out, but "renpy.transition" comes to mind. Have you tried this?

Code: Select all

   show girl with dissolve
    $ e_face = "angry"
    "test"
    $ renpy.transition(dissolve)
    $ e_face = "cheeky"
Just a suggestion though.
If that doesn't work you might want to look into a custom version of ConditionSwitch with DynamicDisplayable?

Alternatively, maybe try this in conjunction with the ATL animation:

Code: Select all

image face_cheeky:
    "cheeky face.png"
    alpha 0.0
    linear .5 alpha 1.0

[...]

   show girl with dissolve
    $ e_face = "angry"
    "test"
    $ e_face = "cheeky"
    $renpy.redraw("girl", 0.0)
In Orbit [WIP] | Gliese is now doing weekly erratic VN reviews! The latest: Halloween Otome!
Gliese Productions | Facebook | Twitter
Image

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Conditionswitch and transitions

#3 Post by Elmiwisa »

There are no way to use it with ConditionSwitch. However, look like what you are trying to do can be done by having 3 different images, and just use the regular show function to show the correct one.
For example:

Code: Select all

image Girl angry=...
image Girl cheeky=...
image Girl None=...
python:
    def show_Girl(face):
        $renpy.show("Girl "+face)
        $renpy.with_statement(dissolve)

...

$show_Girl(e_face)

User avatar
Badriel
Regular
Posts: 66
Joined: Mon Jul 23, 2012 1:10 pm
Completed: Clockwork City
Tumblr: badrielart
Deviantart: badriel
Contact:

Re: Conditionswitch and transitions

#4 Post by Badriel »

Greeny wrote:I think it's not possible, not within ConditionSwitch. You'll need to find some kind of workaround...

I didn't try this out, but "renpy.transition" comes to mind. Have you tried this?

Code: Select all

   show girl with dissolve
    $ e_face = "angry"
    "test"
    $ renpy.transition(dissolve)
    $ e_face = "cheeky"
Just a suggestion though.
If that doesn't work you might want to look into a custom version of ConditionSwitch with DynamicDisplayable?

Alternatively, maybe try this in conjunction with the ATL animation:

Code: Select all

image face_cheeky:
    "cheeky face.png"
    alpha 0.0
    linear .5 alpha 1.0

[...]

   show girl with dissolve
    $ e_face = "angry"
    "test"
    $ e_face = "cheeky"
    $renpy.redraw("girl", 0.0)
I'm afraid none of these works.

Elmiwisa wrote:There are no way to use it with ConditionSwitch. However, look like what you are trying to do can be done by having 3 different images, and just use the regular show function to show the correct one.
For example:

Code: Select all

image Girl angry=...
image Girl cheeky=...
image Girl None=...
python:
    def show_Girl(face):
        $renpy.show("Girl "+face)
        $renpy.with_statement(dissolve)

...

$show_Girl(e_face)
This code looks interesting, but when I put it into motion, I get error "invalid syntax $=>renpy.show("Girl"+face)"

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Conditionswitch and transitions

#5 Post by Elmiwisa »

Oh right put the $ on these 2 lines by mistake. :oops: Just remove them.

User avatar
Badriel
Regular
Posts: 66
Joined: Mon Jul 23, 2012 1:10 pm
Completed: Clockwork City
Tumblr: badrielart
Deviantart: badriel
Contact:

Re: Conditionswitch and transitions

#6 Post by Badriel »

Elmiwisa wrote:Oh right put the $ on these 2 lines by mistake. :oops: Just remove them.
Oh, that worked! Renpy.show isn't described well enough in the documentation, so I lack some knowledge about it.
But it doesn't really solve my problem, because I'll need to define all possible combinations.
Let's assume I've got a character with 8 poses, 10 separate lips and 10 separate eyes.
Defining it all would result in 640 possible combinations, and I'd like to avoid that. It'd be perfect if I could use something like:

Code: Select all

 $show_Girl('pose1', 'lips_sad', 'eyes_confused')

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Conditionswitch and transitions

#7 Post by Elmiwisa »

Badriel wrote:
Elmiwisa wrote:Oh right put the $ on these 2 lines by mistake. :oops: Just remove them.
Oh, that worked! Renpy.show isn't described well enough in the documentation, so I lack some knowledge about it.
But it doesn't really solve my problem, because I'll need to define all possible combinations.
Let's assume I've got a character with 8 poses, 10 separate lips and 10 separate eyes.
Defining it all would result in 640 possible combinations, and I'd like to avoid that. It'd be perfect if I could use something like:

Code: Select all

 $show_Girl('pose1', 'lips_sad', 'eyes_confused')
Eh... :oops: well then just go back to ConditionSwitch then. I just find it unnecessary when you have only 1 thing you can change, so I did not use it. But the situation is never at all about ConditionSwitch.
ConditionSwitch will never do the transition for you. It will update an image base on the condition whenever: (a) automatically upon an interaction, such as a say statement or a menu; (b) when you force it to do so by a show statement or something. In your original code, all you did is changing the variable. ConditionSwitch do not update the image when you change the variable, but when you reach the say statement. What the function did in my code is that it take the initiative and automatically do a show statement with the with statement to make the transition, because ConditionSwitch won't do it if you left it to its own device. You could do away with the function if you are willing to write a bunch of statement each time (at least 2: one for changing the variable, and one for the transition). Using renpy.show is just because the function is in Python and thus cannot use Ren'Py statement.
So you can do it like this:

Code: Select all

image Girl=LiveComposite(...,ConditionSwitch(...),...,ConditionSwitch(...),...,ConditionSwitch(...))
init python:
    def show_Girl(poses,lips,eyes):
        global e_poses,e_lips,e_eyes
        e_poses,e_lips,e_eyes=poses,lips,eyes
        renpy.show("Girl")
        renpy.with_statement(dissolve)

...

label start:
    #declare e_poses,e_lips,e_eyes here
...
   show_Girl("relaxed","smile","swirly")
Oh and I should warn you, in case this is not what you want. Here you are using transition. Which means the whole screen are going to get affected, and also the say window will disappear during the transition. If you use anything other than some version of dissolve transition, the effect of the transition will be rather noticeable in the background. Just thought this is worth mentioning since I notice that you also tried to use transform in the first post.

User avatar
Badriel
Regular
Posts: 66
Joined: Mon Jul 23, 2012 1:10 pm
Completed: Clockwork City
Tumblr: badrielart
Deviantart: badriel
Contact:

Re: Conditionswitch and transitions

#8 Post by Badriel »

Elmiwisa wrote:Eh... :oops: well then just go back to ConditionSwitch then. I just find it unnecessary when you have only 1 thing you can change, so I did not use it. But the situation is never at all about ConditionSwitch.
ConditionSwitch will never do the transition for you. It will update an image base on the condition whenever: (a) automatically upon an interaction, such as a say statement or a menu; (b) when you force it to do so by a show statement or something. In your original code, all you did is changing the variable. ConditionSwitch do not update the image when you change the variable, but when you reach the say statement. What the function did in my code is that it take the initiative and automatically do a show statement with the with statement to make the transition, because ConditionSwitch won't do it if you left it to its own device. You could do away with the function if you are willing to write a bunch of statement each time (at least 2: one for changing the variable, and one for the transition). Using renpy.show is just because the function is in Python and thus cannot use Ren'Py statement.
So you can do it like this:

Code: Select all

image Girl=LiveComposite(...,ConditionSwitch(...),...,ConditionSwitch(...),...,ConditionSwitch(...))
init python:
    def show_Girl(poses,lips,eyes):
        global e_poses,e_lips,e_eyes
        e_poses,e_lips,e_eyes=poses,lips,eyes
        renpy.show("Girl")
        renpy.with_statement(dissolve)

...

label start:
    #declare e_poses,e_lips,e_eyes here
...
   show_Girl("relaxed","smile","swirly")
Oh and I should warn you, in case this is not what you want. Here you are using transition. Which means the whole screen are going to get affected, and also the say window will disappear during the transition. If you use anything other than some version of dissolve transition, the effect of the transition will be rather noticeable in the background. Just thought this is worth mentioning since I notice that you also tried to use transform in the first post.

Ah, brilliant! I've modified this code slightly to make it even easier, and came up with this:

Code: Select all

init python:
    def show_Girl(face,body):
        global e_face,e_body
        e_face,e_body=face,body
        renpy.show("girl")
        renpy.with_statement(dissolve)

image girl:
    LiveComposite(
        (566,800),
        (0,0), "Girl %s.png"%e_body, 
        (0,0), "eyes %s.png"%e_face, 
        )
init:
    $ e_face = 'angry'
    $ e_body = 'bikini'

label start:
test1"
    $show_Girl("cheeky","bikini")
    "Hello"
    $show_Girl("angry","formal")
Now I don't even have to define any images, just type the name i want, and it'll define the image for me :D

Graph
Veteran
Posts: 230
Joined: Sat Jul 03, 2010 7:22 pm
Completed: Touhou Mecha Chap. 1
Projects: Touhou Mecha, Eastern Starlight Romance
Organization: Dai-Sukima Dan
Contact:

Re: Conditionswitch and transitions [SOLVED]

#9 Post by Graph »

W, whoa.

This is the 'ConditionSwitch with transitions' technique everyone's been waiting for, isn't it?! Excellent work. You guys rock!

EDIT:
How do you guys position the sprites though? Using stuff like "at right" or even general ATL blocks.

User avatar
Arowana
Miko-Class Veteran
Posts: 531
Joined: Thu May 31, 2012 11:17 pm
Completed: a2 ~a due~
Projects: AXIOM.01, The Pirate Mermaid
Organization: Variable X, Navigame
Tumblr: navigame-media
itch: navigame
Contact:

Re: Conditionswitch and transitions [SOLVED]

#10 Post by Arowana »

Hey all, I was trying the ConditionSwitch with transitions code that Elmiwisa wrote here, but I cannot get the desired dissolve effect using that method. Is it true that ConditionSwitch only updates the image when you reach the say statement? If so, wouldn't something like this also work?

Code: Select all

$ e_face = "angry"
show girl with dissolve
"The transition is before the say statement, but the image isn't dissolving."
Still no dissolve. What am I missing?

I should say that Badriel's code is great and works well, but it avoids the use of ConditionSwitch completely. I'd really like to know if there's a straightfoward way to do ConditionSwitch with transitions like Elmiwisa is suggesting.
Complete: a2 ~a due~ (music, language, love)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)

Image

Post Reply

Who is online

Users browsing this forum: No registered users