[SOLVED]ConditionSwitch "else" and "None" are posible?

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

[SOLVED]ConditionSwitch "else" and "None" are posible?

#1 Post by johandark »

Let´s imagine I have this code:

Code: Select all

$ blue = True
$ red = True

transform positionA():
    xpos 0.5 ypos 0.5
    linear 2.0 xpos 0.0 ypos 0.0
    
transform positionB():
    xpos -0.5 ypos -0.5
    linear 2.0 xpos 0.0 ypos 0.0
     
    contains: #d_legr Only visible if there´s blue.
        ConditionSwitch(points_high and blue, At("ball 02", positionA), #If it´s $ blue == True.
                                    points_med and blue, At("ball 01", positionA), 
                                    points_low and blue, At("ball 00", positionA),
                                    
                                    ## If there´s anything else is Invisible or None
                                    else, (None))
There are 3 different Balls "Ball 00", "Ball 01" and 2 "Ball 02". There are 2 positions "PositionA" and "PositionB", but in this case, I just care about the first position.

The thing is, in this "contain" I would like that whatever is not "$ blue ==True" Becomes invisible or inexistent, so "None".

So... Is there a way to say with ConditionSwitch...?

Code: Select all

else:

    None
Thanks!
Last edited by johandark on Mon Jan 09, 2017 12:59 pm, edited 1 time in total.
Image

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: ConditionSwitch "else" and "None" are posible?

#2 Post by nyaatrap »

"True", Null(). This code means if condition reached here, it shows Null displayable.
Though I don't think conditionswitch in ATL works, because ATL only evaluates values when it's showing or replacing.

User avatar
johandark
Veteran
Posts: 356
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 "else" and "None" are posible?

#3 Post by johandark »

nyaatrap wrote:"True", Null(). This code means if condition reached here, it shows Null displayable.
Though I don't think conditionswitch in ATL works, because ATL only evaluates values when it's showing or replacing.
Ok... The thing is this works PERFECTLY.

I understand Null() Completely.

But I would appreciate a little more explanation about "True"...

I used this before:

Code: Select all

not blue, Transform("aftermorning04_bg_fittingroom_mast_dass_14_d_legr_wet 02", alpha=0.0))
But obviously Null() is better because it doesn´t load the image and it goes faster.

But "True"? Why does it work? What if There´s a mix of True Conditionals and False Conditionals? It would still work as "else"?..

I don´t get it.. :S

Sorry for my ignorance... :(
Image

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: ConditionSwitch "else" and "None" are posible?

#4 Post by xela »

Like what we're doing? Support us at:
Image

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: ConditionSwitch "else" and "None" are posible?

#5 Post by Divona »

johandark wrote:
nyaatrap wrote:"True", Null(). This code means if condition reached here, it shows Null displayable.
Though I don't think conditionswitch in ATL works, because ATL only evaluates values when it's showing or replacing.
But I would appreciate a little more explanation about "True"...
But "True"? Why does it work? What if There´s a mix of True Conditionals and False Conditionals? It would still work as "else"?..
In ConditionSwitch, when no any other conditions are match, it will end up display True condition. Yes, it is equivalence to "else" in this case, if you want to see it that way. No particular reason to think too hard about it. It just made to work like this.

Code: Select all

        ConditionSwitch(
            "points_high and blue", At("ball 02", positionA), #If it´s $ blue == True.
            "points_med and blue", At("ball 01", positionA), 
            "points_low and blue", At("ball 00", positionA),
            "True", Null()
        )
Completed:
Image

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2439
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: ConditionSwitch "else" and "None" are posible?

#6 Post by Ocelot »

when no any other conditions are match, it will end up display True condition
The main reason, is that if no condition matched, then ConditionSwitch throws an error. So you need at least one condition which is always true. 'True' is always true, so it is often used in this case.
< < insert Rick Cook quote here > >

User avatar
johandark
Veteran
Posts: 356
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 "else" and "None" are posible?

#7 Post by johandark »

I´ll try to take a look on this web, it looks really interesting! Thanks.

---

Thanks for your help all of you! I´m very noob on programming but I´m growing on my knowledge thanks to you!

;)
Image

Post Reply

Who is online

Users browsing this forum: Bing [Bot]