Page 1 of 1

Suggestion: Could "say" auto clean up image tags?

Posted: Thu Feb 07, 2019 10:55 pm
by strayerror
In a game where characters have speaking poses, at it's most verbose, a typical conversation might look something like:

Code: Select all

label example:
    show sam idle
    sam "( Oooh, I see Bob, I'm going to surprise him! )"
    show sam shout
    sam "Hello, Bob!"
    show sam -shout
    show bob surprised talk
    bob "Hi, Sam! Didn't see you there, how's it going?"
    show bob -talk
    show sam talk
    sam "Great, thanks for asking!"
    show sam -talk
The same conversation with images attached to the characters would would look more like:

Code: Select all

label example:
    sam idle "( Oooh, I see Bob, I'm going to surprise him! )"
    sam shout "Hello, Bob!"
    show sam -shout
    bob surprised talk "Hi, Sam! Didn't see you there, how's it going?"
    show bob -talk
    sam talk "Great, thanks for asking!"
    show sam -talk
However, it would be really really nice to be able to do something like:

Code: Select all

label example:
    sam idle "( Oooh, I see Bob, I'm going to surprise him! )"
    sam +shout "Hello, Bob!"
    bob surprised +talk "Hi, Sam! Didn't see you there, how's it going?"
    sam +talk "Great, thanks for asking!"
Where the tags marked with a + (+ is just an example) are automatically cleared after the line of dialogue they relate to.

Re: Suggestion: Could "say" auto clean up image tags?

Posted: Thu Feb 07, 2019 10:58 pm
by philat

Re: Suggestion: Could "say" auto clean up image tags?

Posted: Fri Feb 08, 2019 1:52 am
by strayerror
Thanks, that definitely very useful for basic cases, but unfortunately that doesn't really cover what I'm suggesting, although it's certainly related.

config.speaking_attribute only kicks in when no other tags are provided to the say statement (so Bob would have to use one statement to switch to surprised and a second to say something using the speaking_attribute), and it's limited to one specific tag. So in the provided example, it could be talk or shout but not both. Additionally it wouldn't be possible to use it to support transient actions, such as hand gestures like a wave or salute.

Re: Suggestion: Could "say" auto clean up image tags?

Posted: Fri Feb 08, 2019 3:22 am
by philat
strayerror wrote: Fri Feb 08, 2019 1:52 am config.speaking_attribute only kicks in when no other tags are provided to the say statement (so Bob would have to use one statement to switch to surprised and a second to say something using the speaking_attribute)
Nope. bob surprised "blah blah" should show bob surprised talk.
strayerror wrote: Fri Feb 08, 2019 1:52 am and it's limited to one specific tag. So in the provided example, it could be talk or shout but not both. Additionally it wouldn't be possible to use it to support transient actions, such as hand gestures like a wave or salute.
That's true. A vast majority of characters should be talking though, rather than shouting.

I mean, I'm not trying to stop you from asking for this feature to be included (although this isn't the forum for it); I was just pointing something out that could be helpful for what you're trying to do that already exists. *shrug*

Re: Suggestion: Could "say" auto clean up image tags?

Posted: Fri Feb 08, 2019 3:42 am
by strayerror
I really appreciate your input, and I apologise if I sounded unnecessarily defensive or combative, that wasn't my intent at all. I only sought to explain the suggestion more thoroughly, in the belief that config.speaking_attribute couldn't do what I needed, but from your reply I think perhaps I've maybe just made some mistakes in using it.

In my current code, in addition to it seeming not to kick in when other attributes are provided, it's also not clearing after the dialogue line as it should. I've been trying to debug it with renpy.get_attributes, but I've not gotten very far with it beyond confirming that the tag remains after the say. I'll be sure to check my renpy version and keep cutting the code down until I get it working and then try building it back up.

If, when I have it working, the suggestion still makes sense in some form, where is the recommended place to be raising it? I had thought this was the correct subforum, but sounds like I goof'd there too. It's been a long night. :oops: *facepalm*

Re: Suggestion: Could "say" auto clean up image tags?

Posted: Fri Feb 08, 2019 4:58 am
by philat
No worries. Try just a clean project with placeholders for bob, bob surprised, bob surprised talk and see how it goes. It's working fine for me in a clean project, latest stable build.

This forum is for questions and troubleshooting -- feature requests should ideally go to viewforum.php?f=32 . Not that there isn't overlap, but for future reference.

Re: Suggestion: Could "say" auto clean up image tags?

Posted: Fri Feb 08, 2019 7:55 am
by Remix
I'd actually suggest a syntax like:

Code: Select all

    e +-happy "add happy and remove it after this line"
    e -+moody "remove moody then re-add it after this line"
For yours, though it is a bit of a workaround, you could utilize the show_ say parameters and use the on show: on hide: events within the say screen to automate one liner tags... (example using a bespoke say screen - and some debug print statements)

Code: Select all

screen say_with_tags(who, what, **kwargs):
    style_prefix "say"

    window:
        id "window"

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                text who id "who"

        text what id "what"

    on 'show' action Function(tag_attributes, add_attrs=True, **kwargs)

    on 'hide' action Function(tag_attributes, add_attrs=False, **kwargs)


init python:

    def tag_attributes(**kwargs):
        layer = "master"
        tag = renpy.get_say_image_tag()
        add_attrs = kwargs.pop('add_attrs', False)
        print("Add Attrs: {}".format(add_attrs))
        current_attrs = list(renpy.get_attributes(tag, layer=layer)) or []
        if add_attrs:
            show_attrs = [ k for k in set( current_attrs + list(kwargs.get('tag_attrs', []))) ]
        else:
            show_attrs = [ k for k in current_attrs if k not in kwargs.get('tag_attrs', []) ]
        print("Before: {} : {}".format(tag, renpy.get_attributes(tag, layer=layer)))
        renpy.game.context().images.attributes[(layer, tag)] = tuple(show_attrs)
        print("After: {} : {}".format(tag, renpy.get_attributes(tag, layer=layer)))

define e = Character("Eileen", screen="say_with_tags", image="e")

label start:

    show e

    e happy "Some words" (show_tag_attrs=['shout','livid'])

    e "More words" (show_tag_attrs=['ventriloquist','sneaky'])
Note: I've not tested it with images to check if the displayed image respects the tags (whether the on show and on hide run before the image is shown)

Re: Suggestion: Could "say" auto clean up image tags?

Posted: Fri Feb 08, 2019 9:46 am
by PyTom
I need to think about this, but I like the basic concept. I'm debating if this should go in 7.1.4 or 7.1.5, but I think I really like it.

What I'm sort of thinking of this that we'd have a syntax.

Code: Select all

     e @ vhappy "I'm feeling really happy right now."
The space after the @-sign is optional, and the @ sign is here to indicate this is the emotion 'at' this line. The semantics of this that I'm thinking of would be.

1. Ren'Py would back up the image with the character's image tag that is currently showing, if any.
2. Ren'Py would then do 'show eileen vhappy'. This would work for any number of image attributes, with a single @-sign.
3. The dialogue would be displayed.
4. Ren'Py would restore the backed up image.

Any thoughts?

I do suspect the space after the @sign would normally be eliminated, so things like:

Code: Select all

e @-sad "At least I'm not sad."
e @happy "I'm happy." 
would work.

Re: Suggestion: Could "say" auto clean up image tags?

Posted: Fri Feb 08, 2019 12:47 pm
by rames44
That sounds like a nice feature.

I could also see value in the “minus” and “plus” syntax by themselves (i.e. without the save/restore functionality implied by the @ sign)

Re: Suggestion: Could "say" auto clean up image tags?

Posted: Fri Feb 08, 2019 5:26 pm
by strayerror
The @ delimiter sounds like a good choice to split the two attribute lists; persistent vs transient. So long as it's still possible to use persistent attribute mutations in the same line. i.e.

Code: Select all

e incredulous -blink @ talk -armcross "Didn't expect to see you here!"
---

If you'll humour me, in a world free from legacy concerns, being able to do stuff like the example below would be really nice. Having + and - denote tag/attribute mutations, while absence of either would result in resetting them, and only attributes prefixed with + or - would be valid beyond the proposed @ delimiter. This syntax modification would make the attribute mutations much more explicit and distinct from regular tag usage and (IMO) more intuitive to reason about without requiring the domain knowledge that tags are cumulative. That said, I do appreciate that would be a breaking change and would at the very least require a project level config flag to enable it (perhaps config.cumulative_attributes = True|False?), but it seemed like the right time to bring it up as it's tangentially related to this feature/suggestion.

Code: Select all

show eileen eyecontact at left

e +wave @ +talk "Hi there!" # eyecontact, wave, talk
e "( Why am I still waving? I should stop! )" # eyecontact, wave
e -wave @ +talk +blush -eyecontact "Oops! Sometimes my arm just gets carried away!" # talk, blush
e @ +talk "Let's just pretend that didn't happen, ok?" # eyecontact, talk
e sit "( Perhaps I'll be calmer sitting down )" # sit (all other attrs have been reset)
---

P.S. Also, I did eventually get the config.speaking_attribute speaking attribute working. I had been working on the 7.0.0 SDK, where it didn't always clear tags when using layeredimages. Updating to 7.1.3 solved that particular issue. :oops: