ConditionSwitch doesn´t work with transformations... help.

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
johandark
Veteran
Posts: 355
Joined: Sat Apr 30, 2016 11:04 am
Completed: Wild Guards, In Dreams
Projects: Pact with a witch
Deviantart: johandarkweb
Location: Barcelona
Contact:

ConditionSwitch doesn´t work with transformations... help.

#1 Post by johandark »

I usually use this for images with conditionals:

Code: Select all

        #Eyes
        
    contains: #Eyes
        ConditionSwitch(night04_pedrera_blowjob_pov_004_Con_eyes_camera03, At("night04_pedrera_blowjob_pov_n_chest_eyes_03_superdark", night04_pedrera_blowjob_pov_004_trans_n_head),
                                    night04_pedrera_blowjob_pov_004_Con_eyes_front03, At("night04_pedrera_blowjob_pov_n_chest_eyes_03_superdark", night04_pedrera_blowjob_pov_004_trans_n_head),
                                    night04_pedrera_blowjob_pov_004_Con_eyes_front05, At("night04_pedrera_blowjob_pov_n_chest_eyes_05_superdark", night04_pedrera_blowjob_pov_004_trans_n_head),
                                    night04_pedrera_blowjob_pov_004_Con_eyes_front06, At("night04_pedrera_blowjob_pov_n_chest_eyes_06_superdark", night04_pedrera_blowjob_pov_004_trans_n_head),
                                    "True", Null())
ConditionSwitch works prety fine here.

But for transformations, ConditionSwitch doesn´t work.

Is there anyway to work this code?:

Code: Select all

transform night04_pedrera_blowjob_ghost_01_position_024:
    zoom 0.5 yalign -0.8  xalign -1.5 alpha 0.0
    
    parallel: #Here starts the my question...
        if night04_pedrera_blowjob_pov_005_Con_Body_LickEggs == True:
            night04_pedrera_blowjob_ghost_01_body_transparency_024
        else:
            night04_pedrera_blowjob_ghost_01_eye_transparency_024
        repeat
But actually working fine... ^^ Since if and else... seems doesn´t work at all with transformations. ^^

Thanks!
Image

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: ConditionSwitch doesn´t work with transformations... hel

#2 Post by Remix »

I would suggest moving the conditional logic outside the transform definition, thus allowing you to re-use the transform nicely:

Transforms can only do a rather restricted set of actions as they are Ren'py code... they cannot themselves contain python logic...

See ATL - External Function Call for some info on what they can contain.

You can pass variables to ATL though, so could pass in all you need... I still advise keeping the logic in-line in the script though.
Some sample code that might get you moving

Code: Select all

define forest = Image("images/forest.png")
init python:
    ## Just a function to show we can pass a variable out and back
    def get_img(a):
        # You *could* put logic here
        return a

transform night04_pedrera_blowjob_ghost_01_position_024(img, zoom, yalign, xalign, alpha, xpos, ypos):
    # passing in all the variables to the transform
    contains get_img(img)
    # zoom (action) zoom (passed variable)
    # Maybe should name the vars different to avoid confusion
    zoom zoom yalign yalign xalign xalign alpha alpha xpos xpos ypos ypos
    linear 10.0 xpos xpos+2000 ypos ypos+1000


label start:
    "Hello, world."
    # I tried 'show None at...'
    # Tried 'show Null at...'
    # Both used lookup to find missing image, so it is best to use the default image you want even though you are passing in the shown one
    show forest at night04_pedrera_blowjob_ghost_01_position_024(forest, 0.5, 0.5, 0.5, 0.8, 100, 100)
I would personally advise not to pass in the image though, just recode the transform to not use img and inline the logic...

Code: Select all

transform night04_pedrera_blowjob_ghost_01_position_024(zoom, yalign, xalign, alpha, xpos, ypos):
    zoom zoom yalign yalign xalign xalign alpha alpha xpos xpos ypos ypos
    linear 10.0 xpos xpos+2000 ypos ypos+1000

label start:
    "Hi World" 
    if night04_pedrera_blowjob_pov_005_Con_Body_LickEggs == True:
        show night04_pedrera_blowjob_ghost_01_body_transparency_024 at night04_pedrera_blowjob_ghost_01_position_024(0.5, 0.5, 0.5, 0.8, 100, 100)
    else:
        show night04_pedrera_blowjob_ghost_01_eye_transparency_024 at night04_pedrera_blowjob_ghost_01_position_024(0.5, 0.5, 0.5, 0.8, 100, 100)
Much more Ren'py-esque
Frameworks & Scriptlets:

User avatar
johandark
Veteran
Posts: 355
Joined: Sat Apr 30, 2016 11:04 am
Completed: Wild Guards, In Dreams
Projects: Pact with a witch
Deviantart: johandarkweb
Location: Barcelona
Contact:

Re: ConditionSwitch doesn´t work with transformations... hel

#3 Post by johandark »

But, what you did is acting outside of the transform...

Is there no way to act inside the transform with a conditional? Even if it´s using it outside the transform, but working before the transform, not after.

Thanks! ;)
Image

Post Reply

Who is online

Users browsing this forum: Google [Bot]