Live Composite with optional stuff [Solved]

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
sunwave
Regular
Posts: 45
Joined: Fri Apr 15, 2016 2:26 pm
Location: Netherlands
Contact:

Live Composite with optional stuff [Solved]

#1 Post by sunwave »

So I was trying to switch from static sprites to a livecomposite setup because my artist went out of their way to not just deliver me some nice characters, but also the PSD files with several interchangeable poses. SO... now I feel compelled to use them (which would obviously give me lots of options in-game). This specific character consists of:
- A base (bottom layer)
- A head with expression (middle layer)
- An arm pose (on top)
- A blush (optional layer)

Now I have set up the code like this:

Code: Select all

#########################################################################
## SERENA

define S = Character('Serena', color="#FF6600", who_suffix = ':', what_prefix='"', what_suffix='"')
define S_who = Character('???', color="#FF6600", who_suffix = ':', what_prefix='"', what_suffix='"')

default s_head = "neutral"
default s_blush = None
default s_arms = "neither"

image serena = LiveComposite(
    (1719, 5448),
    (0, 0), "images/characters/serena/base/base.png",
    (0, 0), "images/characters/serena/head/[s_head].png",
#   (0, 0), "images/characters/serena/blush/[s_blush].png",
    (0, 0), "images/characters/serena/arms/[s_arms].png"
)

#########################################################################
### Technical game start

label start:

    stop music
    scene black
    window auto
    
#########################################################################
### Game start

    scene bg hallway1
    "This is the start of the test."

    show serena
    S "This is me! Pose me however you want!"
    $ s_head, s_arms = "annoyed", "both"
    S "Just... no weird things!"
    S "Get it?"
#   $ s_blush = "blush1"
#   S "Hey!"

    return
Sooo.... it works nice (ignoring the fact that the image is still its original size, haha).
But if I try to add the blush, it will complain that it can't find the blush file (obviously, because it's searching for a file with an empty name). Is there a way to add the blush to the composite image ONLY if the blush variable has a value? It probably could work with a conditionswitch but I can't seem to get it to work. I don't want to put an empty file in the "blush/noblush.jpg" because I simply don't want an empty file if there is a better way.
Last edited by sunwave on Mon Apr 24, 2017 4:41 pm, edited 1 time in total.

User avatar
Scribbles
Miko-Class Veteran
Posts: 636
Joined: Wed Sep 21, 2016 4:15 pm
Completed: Pinewood Island, As We Know It
Projects: In Blood
Organization: Jaime Scribbles Games
Deviantart: breakfastdoodles
itch: scribbles
Location: Ohio
Contact:

Re: Live Composite with optional stuff

#2 Post by Scribbles »

Probably not the best method - but what I used - I created a image with 1% opacity and used that as the "non" blush image to switch between

someone has to have a better way of doing that though lol
Image - Image -Image

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Live Composite with optional stuff

#3 Post by Imperf3kt »

Can't you just make two live composite images?
One with the blush file, one without.

Then when you show the image, add a conditional there.

Knowing how you plan to use the blush would be helpful. Is it set from the main menu, or does the character blush under certain responses?
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
sunwave
Regular
Posts: 45
Joined: Fri Apr 15, 2016 2:26 pm
Location: Netherlands
Contact:

Re: Live Composite with optional stuff

#4 Post by sunwave »

Oh, you mean making one conditionswitch for the blush (or not), and if s_blush has a value, use one of the composites (with blush) and if it has no value use the other composite (without blush)? That would perhaps be possible. I was messing with the conditonswitch INSIDE the composite but I didn't consider the other way around. I'll try that now. I'll let you know if it worked or not. (And yeah, I just want to be able to change a variable on-the-fly to turn off/on the blush on her character model).

@Scribbles: Yeah, right now I have a 1x1 pixel image with an empty layer in it saved as "noblush". So basically the same thing. Haha.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Live Composite with optional stuff

#5 Post by trooper6 »

What you want is to use a ConditionSwitch in your LiveComposite.
ConditionSwitch is documented here: https://www.renpy.org/doc/html/displaya ... tionSwitch

Your code would look like something like this:

Code: Select all

default s_head = "neutral"
default s_blush = False
default s_arms = "neither"

image serena = LiveComposite(
    (1719, 5448),
    (0, 0), "images/characters/serena/base/base.png",
    (0, 0), "images/characters/serena/head/[s_head].png",
    (0, 0), ConditionSwitch(
        "s_blush == False", Null(),
        "True", "images/characters/serena/blush/blush1.png"),
    (0, 0), "images/characters/serena/arms/[s_arms].png"
)
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
sunwave
Regular
Posts: 45
Joined: Fri Apr 15, 2016 2:26 pm
Location: Netherlands
Contact:

Re: Live Composite with optional stuff [Solved]

#6 Post by sunwave »

Awesome. Works like a charm. =)

Post Reply

Who is online

Users browsing this forum: BBN_VN