Automatically adding "speaking" attribute to speaking character

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
zmook
Veteran
Posts: 421
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Automatically adding "speaking" attribute to speaking character

#1 Post by zmook »

So it seems like it would be convenient to use character callbacks to automatically add the "speaking" attribute to the character's sprite (the main one, not a side image) when they say something, and remove it when they're done. Is there any way to dynamically add or remove an attribute, like "speaking", to a shown image tag?

Basically, how do I automate this?

Code: Select all

    show ellen speaking
    el "Oh! You're interesting."
    show ellen -speaking
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

User avatar
zmook
Veteran
Posts: 421
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: Automatically adding "speaking" attribute to speaking character

#2 Post by zmook »

Hm. Lacking renpy.add_showing_attribute(tag) and renpy.remove_showing_attribute(tag) functions (I've looked for them and can't find them -- if they *do* exist and I just can't find them in the docs please let me know), it seems like an algorithm something like this might work?

Code: Select all

  def speaking_callback_pseudocode():
      for tag in renpy.get_showing_tags():
          if "speaking" in renpy.get_attributes(tag):
                current_attrs = renpy.get_attributes(tag)
                remove "speaking" from current_attrs
               reshow image tag with current_attrs # hm, I don't actually see a renpy.show_image(tag, attrs) function in the docs?
      speaker_tag = renpy.get_say_image_tag()
      reshow image speaker_tag with current_attrs+"speaking"
At least, it seems like it might work if renpy.show_image() exists, but I don't see it with the other image functions at https://www.renpy.org/doc/html/displayi ... -functions
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM


User avatar
zmook
Veteran
Posts: 421
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: Automatically adding "speaking" attribute to speaking character

#4 Post by zmook »

colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

Post Reply

Who is online

Users browsing this forum: Google [Bot]