Showing multiple images for one condition live composite

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
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Showing multiple images for one condition live composite

#1 Post by namastaii » Tue May 10, 2016 1:59 pm

Sorry I currently have no internet at my house for the time being so I am on my phone.. But still working on my game. When I was a lot newer to Ren'Py I had a lot of tedious code set up because I didn't know of more ways to set things up. I didn't know about ConditionSwitch for live composite and such so I had a bunch of if statements and a bunch of versions of a live composite with slight changes lol. What I am doing now is condensing those. I can use condition switch for one outcome per condition. But not multiple. (showing multiple images of one condition is true) how do I go about this? I tried using an if statement inside but it also won't seem to let me do more than one outcome per condition. What would the proper syntax for this be or can you do it at all? I hope this makes sense. I can't share my code on my phone..

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Showing multiple images for one condition live composite

#2 Post by xavimat » Tue May 10, 2016 2:19 pm

Have you tried nesting some ConditionSwitch() inside a LiveComposite()?
https://www.renpy.org/doc/html/displaya ... eComposite
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Showing multiple images for one condition live composite

#3 Post by namastaii » Tue May 10, 2016 2:29 pm

Yes that's what I mean. It works but I can't make one condition have multiple outcomes. It only Does The first outcome

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Showing multiple images for one condition live composite

#4 Post by namastaii » Tue May 10, 2016 2:31 pm

For instance I want three images to only show (outfit pieces) if a variable is true. It only reads the first image listed and then the character is basically half naked

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Showing multiple images for one condition live composite

#5 Post by xavimat » Tue May 10, 2016 3:15 pm

Can you show your code?
Is it something like this?:

Code: Select all

image test = LiveComposite(
    (300, 600),
    (0, 0), ConditionSwitch(
        "var == 1", "top1.png",
        "var == 2", "top2.png",
        "True", "top3.png"),
    (0, 0), ConditionSwitch(
        "var == 1", "middle1.png",
        "var == 2", "middle2.png",
        "True", "middle3.png"),
    (0, 0), ConditionSwitch(
        "bott_var == 1", "bottom1.png",
        "bott_var == 2", "bottom2.png",
        "True", "bottom3.png")
    )
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Showing multiple images for one condition live composite

#6 Post by namastaii » Tue May 10, 2016 3:39 pm

I can't post code I'm on my phone and yes it looks like that. I need it to be "var == True", "mypic1.png", "mypic2.png", "mypic3.png"

I need three images to show from one variable. It doesn't work if I put them in one line like above and if I do
"var == True", "mypic1.png",
"var == True", "mypic2.png"

That doesn't work either. It only reads the first one. Understand?

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Showing multiple images for one condition live composite

#7 Post by xavimat » Tue May 10, 2016 4:00 pm

I think I understand.
I've tested my code and it works, but only one image of every ConditionSwitch will show, and these images are nested in the LiveComposite.
In my example, if you set "var=True" you will see "top1.png" and "middle1.png". The two of them nested inside the LiveComposite.

Another way is to nest several LiveComposite inside one ConditionSwitch, maybe this makes more sense to your needs:

Code: Select all

image test2 = ConditionSwitch(
    "var", LiveComposite(
        (200,100),
        (0, 0), "mypic1.png",
        (50, 0), "mypic2.png",
        (100, 0), "mypic3.png"),
    "True", LiveComposite(
        (200,100),
        (0, 0), "mypic4.png",
        (50, 0), "mypic5.png",
        (100, 0), "mypic6.png")
    )
In this example, when var=True you'll see mypic1, 2 and 3. If it's False, you'll see mypic4, 5, 6.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Showing multiple images for one condition live composite

#8 Post by namastaii » Tue May 10, 2016 4:25 pm

The last example might work. I will try that out

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Showing multiple images for one condition live composite

#9 Post by namastaii » Tue May 10, 2016 5:12 pm

Well this is actually what I had in the beginning lol I guess there isn't a simpler solution

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Showing multiple images for one condition live composite

#10 Post by xavimat » Tue May 10, 2016 6:04 pm

Well, the thing is, if you want to present different images together, the simplest way is to combine them in a single image with GIMP, Photoshop or similar. I presume that you have the images separated because, in some place, you are going to use them separately, if not, put them together and the code will be simpler.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Showing multiple images for one condition live composite

#11 Post by namastaii » Tue May 10, 2016 7:33 pm

They are separate because they are pieces to the player's character that change. I can't put them together as an image. They all change often

Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: Showing multiple images for one condition live composite

#12 Post by Onishion » Wed May 11, 2016 2:57 am

I think Xavimat's first solution would do what you want:

Code: Select all

image test = LiveComposite(
    (300, 600),
    (0, 0), ConditionSwitch(    #This would display the bottom-most layer, let's say this is the shoes.
        "var == 1", "bottom1.png",
        "var == 2", "bottom2.png",
        "True", "bottom3.png")
    (0, 0), ConditionSwitch(    #This would display a middle later, let's say the pants
        "var == 1", "middle1.png",
        "var == 2", "middle2.png",
        "True", "middle3.png"),
    (0, 0), ConditionSwitch(    #This would display a top layer, let's say the shirt
        "var == 1", "top1.png",
        "var == 2", "top2.png",
        "True", "top3.png"),
    )

In that example, if Var was 1, then it would show the "#1" images for all three layers at once. If Var was 2, then the second set of images would all display. The way Condition Switches work is that it goes down the list from top to bottom, and the first time it hits something that is "true," it takes that result and then quits to the next thing.

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

Re: Showing multiple images for one condition live composite

#13 Post by xela » Wed May 11, 2016 5:44 am

Onishion wrote:I think Xavimat's first solution would do what you want:
Yeap, it was the correct answer :)

I think namastaii asked if this was possible:

Code: Select all

image test = LiveComposite(
    (300, 600),
    (0, 0), ConditionSwitch(    #This would display the bottom-most layer, let's say this is the shoes.
        "var == 1", "bottom1.png",
        "var == 2", "bottom2.png",
        "var == 3", "bottom3.png",
        "var == 1", "middle1.png",
        "var == 2", "middle2.png",
        "var == 3", "middle3.png",
        "var == 1", "top1.png",
        "var == 2", "top2.png",
        "var == 3", "top3.png")
    )
aka to have the switch walking through all the conditions and display all matches. There is no native way to do this in Ren'Py but you can write your own class/function/screen that does this in under 5 mins. Ren'Py offers simple and generic tools that get stuff done, solutions tailored to your preferences you have to add yourself.
Like what we're doing? Support us at:
Image

Post Reply

Who is online

Users browsing this forum: Alex, Google [Bot], nyeowmi