Accessing images from code/or setting images as variables

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
netravelr
Miko-Class Veteran
Posts: 504
Joined: Thu Jan 28, 2010 2:31 am
Completed: Culina: Hands in the Kitchen, Culina: The Spirit of Cooking, Saving Zoey
Projects: Love at the Laundromat
Organization: Lakeview Interactive
Deviantart: netravelr
Location: USA
Contact:

Accessing images from code/or setting images as variables

#1 Post by netravelr »

Okay guys,

So right now I'm doing some functions where I want to call different images but at runtime. Now, what I'm actually trying to use as the images are really Live Composites and is far more confusing than what I'm trying to do, so a simpler example of this would be something like:

Code: Select all

image eileen happy = "eileen_happy.png"
image eileen upset = "eileen_upset.png"

if(...):
   $imageToShow = eileen happy
else:
   $imageToShow = eileen upset

show expression imageToShow
Now just make it 30 different image choices and them all being LiveComposites so I can't just put the images actual text, and just using a variable for the character name and expression won't work because the pieces used to create the images are all different, but having it be a variable would work perfectly. Sadly the closest I've found in the documentation is the renpy.image and Image but they don't return anything and I don't think they actually can get something already created, just make new things. Any ideas?
Image
Technical Designer/Programmer
Game Design Portfolio - Project updates on my Twitter
Experienced in: C/C++/C#, Python, Unreal, Unity, and Flash
_________________
"Space can be very lonely. The greatest adventure is having someone share it with you."

Xipomus
Newbie
Posts: 8
Joined: Sun Jan 20, 2013 7:24 pm
Contact:

Re: Accessing images from code/or setting images as variable

#2 Post by Xipomus »

What you probably want to look at is DynamicDisplayable with the ConditionSwitch.
http://www.renpy.org/wiki/renpy/doc/ref ... isplayable

http://www.renpy.org/wiki/ConditionSwitch

I haven't used it personally but it does do what you want to do.

Hopefully it helps some.

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: Accessing images from code/or setting images as variable

#3 Post by OokamiKasumi »

netravelr wrote:... I'm doing some functions where I want to call different images but at runtime. Now, what I'm actually trying to use as the images are really Live Composites ...
Have you tried using just plain show?

Code: Select all

if(...):
   show eileen happy with dissolve
else:
   show eileen upset with dissolve
Because it's LiveComposite, it will swap out the image no matter where the image is on the screen.
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

Post Reply

Who is online

Users browsing this forum: Li yuanlin