Condition Switch within Condition Switch

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
halitsu
Newbie
Posts: 10
Joined: Thu Nov 16, 2017 3:56 am
Contact:

Condition Switch within Condition Switch

#1 Post by halitsu »

Have you ever wanted a condition switch with two tests? I've found that you can nest condition switches inside one another like so:

Code: Select all

image testimage = ConditionSwitch (
    "test1 == 'A'", ConditionSwitch (
        "test2 == 'pose1'", "pose1 A.png",
        "test2 == 'pose2'", "pose2 A.png",
        "test2 == 'pose3'", "pose3 A.png",
        "test2 == 'pose4'", "pose4 A.png",
        "test2 == 'pose5'", "pose5 A.png",
        "True", "pose1 A.png"
        ),
    "test1 == 'B'", ConditionSwitch (
        "test2 == 'pose1'", "pose1 B.png",
        "test2 == 'pose2'", "pose2 B.png",
        "test2 == 'pose3'", "pose3 B.png",
        "test2 == 'pose4'", "pose4 B.png",
        "test2 == 'pose5'", "pose5 B.png",
        "True", "pose1 B.png"
        ),
    "test1 == 'C'", ConditionSwitch (
        "test2 == 'pose1'", "pose1 C.png",
        "test2 == 'pose2'", "pose2 C.png",
        "test2 == 'pose3'", "pose3 C.png",
        "test2 == 'pose4'", "pose4 C.png",
        "test2 == 'pose5'", "pose5 C.png",
        "True", "pose1 C.png"
        ),
    "test1 == 'D'", ConditionSwitch (
        "test2 == 'pose1'", "pose1 D.png",
        "test2 == 'pose2'", "pose2 D.png",
        "test2 == 'pose3'", "pose3 D.png",
        "test2 == 'pose4'", "pose4 D.png",
        "test2 == 'pose5'", "pose5 D.png",
        "True", "pose1 D.png"
        ),
    "True", "pose1 A.png"
    )
Ren'Py will check the first condition then the second.

User avatar
+mike
Newbie
Posts: 7
Joined: Sat Oct 07, 2017 1:50 pm
Contact:

Re: Condition Switch within Condition Switch

#2 Post by +mike »

Well done, thanks!
This opens a whole new range of possibilities to make choices based on conditions.
• make it simple, it should work! •

Post Reply

Who is online

Users browsing this forum: No registered users