Using variable (flag?) for side image when defining characters.

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
stevetrump
Newbie
Posts: 2
Joined: Thu Oct 18, 2018 4:09 am
Contact:

Using variable (flag?) for side image when defining characters.

#1 Post by stevetrump »

Hey guys, I'm a total newbie at this still and I just have a simple question.. At the start of my game you can choose a gender, and I want to show a side image (portrait) of a male or a female depending on your choice. How can I easily do this?

When I define the "you" character at the top I'm able to define the name as a variable you choose later, (using "[name]") how can I do that with the image?

define y = Character ("[name]")

That line works, but adding something like , image="[gender]" doesn't. (gender is defined as either female or male after a menu choice at the start of the game.)

The images display correctly if I just type in image="male", but I want the gender choice to change that tag according to your choice..
Any help?

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Using variable (flag?) for side image when defining characters.

#2 Post by Remix »

You likely want to just interpolate gender into the single defined image:

Code: Select all

default pc_gender = "male"

image side pc = "images/pc_[pc_gender].png"

define pc = Character("[pc_name]")

label start:
    
    pc 'Male Picture "images/pc_male.png"'

    $ pc_gender = "female"
    
    pc 'Female Picture "images/pc_female.png"'
Frameworks & Scriptlets:

stevetrump
Newbie
Posts: 2
Joined: Thu Oct 18, 2018 4:09 am
Contact:

Re: Using variable (flag?) for side image when defining characters.

#3 Post by stevetrump »

Remix wrote: Thu Oct 18, 2018 5:17 am You likely want to just interpolate gender into the single defined image:

Code: Select all

default pc_gender = "male"

image side pc = "images/pc_[pc_gender].png"

define pc = Character("[pc_name]")

label start:
    
    pc 'Male Picture "images/pc_male.png"'

    $ pc_gender = "female"
    
    pc 'Female Picture "images/pc_female.png"'
That worked.. Thank you so much!!

Post Reply

Who is online

Users browsing this forum: apocolocyntose