[Solved]Different images, same variable?

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
kylemercury
Regular
Posts: 39
Joined: Tue Jul 11, 2017 11:19 pm
Contact:

[Solved]Different images, same variable?

#1 Post by kylemercury »

Hey guys I'm trying to learn how to use Ren'py better and I have an issue that's been on my mind for a while.
Let's say In a game that I'm making I have a character who can wear two outfits. As it is now I have the images coded like so:

image girl dressOne = "dressOne.png"
image girl dressTwo = "dressTwo.png"

whenever I want to display her with her current outfit I use an if statement:

if girlOutfit == 0:
show girl dressOne at right
else:
show girl dressTwo at right

Not only do I dislike this way of coding, but it becomes a big hassle when I add even more outfits to the game.
I tried making a current outfit variable "girl currentOutfit" but assigning that to different image .png file when appropriate does not seem to work.

I know there must be a better way, and I've gone through the tutorial and google several times and I'm not adept enough to figure this out on my own.
Thanks in advance for your help.
Last edited by kylemercury on Fri Dec 21, 2018 6:46 pm, edited 1 time in total.

DannX
Regular
Posts: 99
Joined: Mon Mar 12, 2018 11:15 am
Contact:

Re: Different images, same variable?

#2 Post by DannX »

LayeredImages is probably what you need.

There's a tutorial here.

kylemercury
Regular
Posts: 39
Joined: Tue Jul 11, 2017 11:19 pm
Contact:

Re: Different images, same variable?

#3 Post by kylemercury »

I'll check it out, thank you.

rames44
Veteran
Posts: 233
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: Different images, same variable?

#4 Post by rames44 »

You could also look at ConditionalSwitch and DynamicImage

kylemercury
Regular
Posts: 39
Joined: Tue Jul 11, 2017 11:19 pm
Contact:

Re: Different images, same variable?

#5 Post by kylemercury »

I might do that, I downloaded the tutorial and it wont launch.

File "game/definitions.rpy", line 9: expected statement.
layeredimage augistina :

There's errors for all the lines that have "layeredimage" like this.

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: Different images, same variable?

#6 Post by trooper6 »

If you aren't doing a layered image (multiple different images layered on top of each other to create one image), then you don't need layered image. ConditionSwitch or DynamicImage will be better for what you want.

DynamicImage is described here:
https://www.renpy.org/doc/html/changelo ... mic-images
https://www.renpy.org/doc/html/displaya ... namicImage

ConditionSwitch is described here:
https://www.renpy.org/doc/html/displaya ... tionSwitch

Also make sure you are updated to the most recent version of RenPy.
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

kylemercury
Regular
Posts: 39
Joined: Tue Jul 11, 2017 11:19 pm
Contact:

Re: Different images, same variable?

#7 Post by kylemercury »

Appreciated. Thanks for the links.

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: Different images, same variable?

#8 Post by Remix »

Code: Select all

default dress_type = 0
default pose_type = 0

image girl = "images/dress_[dress_type]_pose_[pose_type].png"

label start:
    show girl
    "..."
    $ pose_type = 1 # now shows images/dress_0_pose_1.png
    "..."
I would suggest looking at LayeredImages though or at least checking out image attributes for characters ( so you can write e happy "happy" or e -happy "normal" )
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]