Automatically use transform when showing image

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
David
Newbie
Posts: 6
Joined: Mon Apr 06, 2015 12:44 pm
Contact:

Automatically use transform when showing image

#1 Post by David »

Ren'Py allows you to specify multiple transforms separated by commas when showing a character.

Code: Select all

show person mood at center, mytransform
But is there an easy way to associate a given transform with an image so that it's called implicitly when you show the image? Like so:

Code: Select all

# some code that associates "person" images with mytransform

show person mood at center # actually applies mytransform and center

# some code that associates "person" images with myothertransform

show person mood at right # actually applies myothertransform and right
Note that I'm using automatic image loading and version 6.99.12. Thanks in advance!

jw2pfd
Regular
Posts: 87
Joined: Tue Sep 18, 2012 9:55 pm
Location: DFW, TX, USA
Contact:

Re: Automatically use transform when showing image

#2 Post by jw2pfd »

I think the easiest way is to stick with transforms separated by commas. There are two things I looked up that are very roughly in the ballpark of what you're describing:
https://renpy.org/doc/html/displayables.html#At
https://renpy.org/doc/html/config.html? ... _transform

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

Re: Automatically use transform when showing image

#3 Post by Imperf3kt »

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

David
Newbie
Posts: 6
Joined: Mon Apr 06, 2015 12:44 pm
Contact:

Re: Automatically use transform when showing image

#4 Post by David »

jw2pfd wrote:I think the easiest way is to stick with transforms separated by commas. There are two things I looked up that are very roughly in the ballpark of what you're describing:
https://renpy.org/doc/html/displayables.html#At
https://renpy.org/doc/html/config.html? ... _transform
Hmm, yes, these are very close to what I want, but not quite there. Still, useful to know about and could form part of the solution. Thank you!
Thank you. I had a vague feeling that character callbacks would be the answer when I was doing my own research, but I'm just not sure how exactly.

First off, will either of these be called on a show statement dealing with the character in question? The docs indicate that they are called according to say statements.
docs wrote:"begin"
Called at the start of a say statement.
"show"
Called before showing each segment of dialogue. Dialogue may be separated into multiple segments by the {w} or {p} text tags, but always consists of at least one segment.
Second off, what all gets passed to the callback function (I see it takes **kwargs) and how do I actually make it apply the transform? Is it a case of the current character displayable (hope my terminology is right) being passed in and then I have to call a transform on it and return it? Or does it work in some other way?

I'm still trying to build up a model of how this system works, so please let me know if I'm making any egregious errors in the assumptions I've formulated these questions with.

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

Re: Automatically use transform when showing image

#5 Post by Imperf3kt »

I'm sorry, but I am not skilled enough to answer, which is why I only left a link.
I wish you luck.
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
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Automatically use transform when showing image

#6 Post by PyTom »

config.tag_transform could work, but it's tag rather than image based.

https://www.renpy.org/doc/html/config.h ... _transform
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

David
Newbie
Posts: 6
Joined: Mon Apr 06, 2015 12:44 pm
Contact:

Re: Automatically use transform when showing image

#7 Post by David »

PyTom wrote:config.tag_transform could work, but it's tag rather than image based.

https://www.renpy.org/doc/html/config.h ... _transform
Thank you. After looking further into this, yes -- nearly. I didn't previously understand that tags included character names.

So I can get close to what I want with this (which is to associate transforms to characters), but the trouble is that tag_transform specifies default transform/s to be used in the event where no at clause is defined. Whereas I want to specify transform/s to be used both on their own (no at clause) and in addition to transforms specified by the at clause.

But thanks again -- I now have a clear view of how to achieve what I want to. I would get exactly what I want by changing the behaviour of tag_transform (or a new, similarly named dict) to append itself to the at_list in the show function. Which probably means taking a look at creator-defined statements (or directly altering RenPy's code, but I'd prefer not to). I'll post the solution in this thread once I figure it out.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], IrisColt