How does Condition Swich work?

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
Stainless_Steel
Regular
Posts: 56
Joined: Mon Jun 25, 2012 11:03 pm
Location: TX, USA
Contact:

How does Condition Swich work?

#1 Post by Stainless_Steel » Thu Jun 28, 2012 4:47 pm

I did find example code for how to do a condition swich to change how a character looks in this forum question : http://lemmasoft.renai.us/forums/viewto ... f=8&t=6195 and tried to make sense of it using the condition switch wiki : http://www.renpy.org/wiki/renpy/doc/ref ... tionSwitch , but i don't understand it enough to use it. This was the example code in the question:

Code: Select all

image protagonist composite = LiveComposite((453, 600),
                                        (0, 0), "charactersbody.png",
                                        (0, 0), "charactersface.png",
                                        (0, 0), ConditionSwitch(
                                            "hair_length == 'short-a'", "characters/hair-short-a.png", 
                                            "hair_length == 'short-b'", "characters/hair-short-b.png", 
                                            "hair_length == 'middle-a'", "characters/hair-middle-a.png",
                                            "hair_length == 'middle-b'", "characters/hair-middle-b.png",
                                            "hair_length == 'long-a'", "characters/hair-long-a.png",
                                            "hair_length == 'long-b'", "characters/hair-long-b.png",
                                            ),
                                        (0, 0), ConditionSwitch(
                                            "clothes == 'uniform'", "characters/uniform.png", 
                                            "clothes == 'pajamas'", "characters/pajamas.png",
                                            ),
                                        )
Since I didn't want to start with a ton of differnt options till i could get it to work I shortened it to this:

Code: Select all

image protagonist composite = LiveComposite((453, 600),
                                        (0, 0), "charactersbody.png",
                                        (0, 0), "charactersface.png",
                                        (0, 0), ConditionSwitch(
                                            " hair_length == 'short-a' ", "charactershair_a.png", 
                                            " hair_length == 'short-b' ", "charactershair_b.png", 
                                            ),
                                        (0, 0), ConditionSwitch(
                                            "clothes == 'uniform' ", "uniform.png", 
                                            "clothes == 'pajamas' ", "kimono.png",
                                            ),
                                        )
When the code for the game starts and gets to where I put show protagonist composite I get IndentionError:unexpected indent (<None>, line 1). What am I doing wrong?

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: How does Condition Swich work?

#2 Post by apricotorange » Fri Jun 29, 2012 12:23 am

Don't put extra spaces at the beginning of your strings (specifically, the ones with hair_length).

User avatar
Stainless_Steel
Regular
Posts: 56
Joined: Mon Jun 25, 2012 11:03 pm
Location: TX, USA
Contact:

Re: How does Condition Swich work?

#3 Post by Stainless_Steel » Fri Jun 29, 2012 2:29 pm

ok. I took out the extra spaces at the beginning of the hair_length strings.

Code: Select all

image protagonist composite = LiveComposite((453, 600),
                                        (0, 0), "charactersbody.png",
                                        (0, 0), "charactersface.png",
                                        (0, 0), ConditionSwitch(
                                            "hair_length == 'short-a' ", "charactershair_a.png", 
                                            "hair_length == 'short-b' ", "charactershair_b.png", 
                                            ),
                                        (0, 0), ConditionSwitch(
                                            "clothes == 'uniform' ", "uniform.png", 
                                            "clothes == 'pajamas' ", "kimono.png",
                                            ),
                                        )

Now it has the issue that hair_length is not defined. Not sure how to fix that since hair_length isn't a variable or at least I don't think it is.

User avatar
Showsni
Miko-Class Veteran
Posts: 563
Joined: Tue Jul 24, 2007 12:58 pm
Contact:

Re: How does Condition Swich work?

#4 Post by Showsni » Fri Jun 29, 2012 2:33 pm

hair_length is a variable. It should be defined as 'short-a' if you want the charactershair_a.png picture, or 'short-b' for charactershair_b.png.

User avatar
Stainless_Steel
Regular
Posts: 56
Joined: Mon Jun 25, 2012 11:03 pm
Location: TX, USA
Contact:

Re: How does Condition Swich work?

#5 Post by Stainless_Steel » Fri Jun 29, 2012 2:45 pm

Thank you, that got it to work.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot]