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

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
strayerror
Regular
Posts: 141
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

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

#1 Post by strayerror » Thu Feb 07, 2019 10:55 pm

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.


strayerror
Regular
Posts: 141
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

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

#3 Post by strayerror » Fri Feb 08, 2019 1:52 am

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.

philat
Eileen-Class Veteran
Posts: 1805
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

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

#4 Post by philat » Fri Feb 08, 2019 3:22 am

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*

strayerror
Regular
Posts: 141
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

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

#5 Post by strayerror » Fri Feb 08, 2019 3:42 am

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*

philat
Eileen-Class Veteran
Posts: 1805
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

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

#6 Post by philat » Fri Feb 08, 2019 4:58 am

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.

User avatar
Remix
Eileen-Class Veteran
Posts: 1592
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

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

#7 Post by Remix » Fri Feb 08, 2019 7:55 am

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)
Frameworks & Scriptlets:

User avatar
PyTom
Ren'Py Creator
Posts: 15666
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: Suggestion: Could "say" auto clean up image tags?

#8 Post by PyTom » Fri Feb 08, 2019 9:46 am

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.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

rames44
Veteran
Posts: 231
Joined: Sun May 29, 2016 4:38 pm
Contact:

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

#9 Post by rames44 » Fri Feb 08, 2019 12:47 pm

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)

strayerror
Regular
Posts: 141
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

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

#10 Post by strayerror » Fri Feb 08, 2019 5:26 pm

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:

Post Reply

Who is online

Users browsing this forum: neometalero, PyTom