Necro-ing this thread because I wasn't satisfied with the solution here—it still shows a flicker where it draws the
say screen for the
"{nw}". Similar to Windchimes' situation, I'm using the side image for a POV character, and I really wanted to be able to show their reactions to things. I ended up dipping into a bit of Python for this, but it seems to be working:
Code: Select all
default pov_chara = None
init python:
def set_pov(who):
"""
Sets the current POV character to ``who``, which may be ``None``.
Also clears any attributes.
"""
assert((not who) or (who is ADVCharacter))
store.pov_chara = who
if who:
config.side_image_tag = who.image_tag
pov_attrs()
else:
config.side_image_tag = None
def update_attrs(who, *attrs):
"""
Updates the attributes of ``who`` as if by a ``say`` statement,
but without actually having that character speak a line of dialogue.
Most useful for the POV character.
"""
assert(who is ADVCharacter)
old_attributes = renpy.game.context().say_attributes
try:
renpy.game.context().say_attributes = attrs
who.resolve_say_attributes(predict=False)
finally:
renpy.game.context().say_attributes = old_attributes
def pov_attrs(*attrs):
"""
Updates the attributes of the current POV character, if there is one,
without actually having that character speak a line of dialogue.
"""
if not store.pov_chara:
return
update_attrs(store.pov_chara, *attrs)
# EDIT: I didn't realize I'd need this when I first posted.
config.after_load_callbacks.append(lambda: set_pov(store.pov_chara))
Code: Select all
$ set_pov(eileen) # a Character, not an image tag
eileen "I'm happy. See?"
$ pov_attrs("happy")
"And indeed she was."
This updates an image's attributes; the change will be flushed the next time things are displayed (usually a
with or a line of dialogue). Strictly speaking, only the
update_attrs function is necessary, but I figure I might build more POV functionality on top of this later.
The key feature here is the
resolve_say_attributes function at
renpy/character.py#L843. I don't love that I'm reaching into
say_attributes to do this, even if I'm taking the same sort of precautions that the actual
say implementation does, so maybe we should ask for some kind of offical function to do this? It's
really close to what
resolve_say_attributes already does, just reading the set of attributes from a parameter instead of this shared state in
renpy.game.context(). (Unfortunately I'm not in a position where I can write the patch myself.)
Aside: I did consider using
resolve_say_attributes' existing
wanted and
remove parameters, but that requires keeping track of
what needs to be removed (whatever the current attributes are). That would either mean more work at the use site, or
exclusively using my wrapper functions to change POV expressions rather than normally relying on
say-with-attributes. (Alternately, I could just use a custom screen for this, or even a plain old image on a non-default layer, but the side image functionality is
really close to what I want. I think.)
Note that I've only tested this with the version I have installed at the moment, which is 7.1.3.1092.