Page 1 of 1

[bug] config.say_menu_text_filter doesn't work with menus?

Posted: Wed Apr 21, 2021 4:16 am
by itoril
Hi everyone.

First of all I want to say I scoured the forums looking for this issue in case it was known. Also, I'm not sure if it's actually a bug or if I'm just doing something wrong. I seem to get different results with a say statement, versus a menu statement. I borrowed Remix's code here. I was testing this with a comma that was inside a menu statement. It didn't work for me, so I spent a few hours poking it with a stick trying to figure out what I'd done wrong. After a bit of desperation, I tested it with a say statement outside of the menu statement, and it works fine.

Is this a limitation of "config.say_menu_text_filter", or is it a limitation of the "wait" text tag, or is it a bug after all? Here are a couple of code examples to explain what I've done and what results I got...

This works fine - the wait tags are injected into the say statement when there's a comma or full stop inside the statement.

Code: Select all

init python:

    def alter_say_strings( str_to_test ):
        str_map = {
            ". " : ". {w=0.75}", 
            ", " : ", {w=0.45}",
        }
        for key in str_map:
            str_to_test = str_to_test.replace( key, str_map[ key ] ) 
        return str_to_test

define config.say_menu_text_filter = alter_say_strings

"The comma in this statement, pauses the text for 0.45 seconds."
This doesn't work - although I'm using the same code, and the function describes itself as working with both say and menu statements, in the documentation.

Code: Select all

init python:

    def alter_say_strings( str_to_test ):
        str_map = {
            ". " : ". {w=0.75}", 
            ", " : ", {w=0.45}",
        }
        for key in str_map:
            str_to_test = str_to_test.replace( key, str_map[ key ] ) 
        return str_to_test

define config.say_menu_text_filter = alter_say_strings

menu:
    "The comma in this statement, is just ignored."
	
    "Option One.":
    "The first option was chosen."

    "Option Two.":
    "The second option was chosen."

Re: [bug] config.say_menu_text_filter doesn't work with menus?

Posted: Thu Apr 22, 2021 2:24 pm
by itoril
I just want to add to this: I also tried out the Character Callbacks example in that article. While the beeping sound works in say statements, it doesn't work during menu statements. I'm not sure if this is related, but I have a hunch it is.

Re: [bug] config.say_menu_text_filter doesn't work with menus?

Posted: Thu Apr 22, 2021 3:28 pm
by itoril
For anyone who's interested: I've come up with a workaround. It's ever so slightly annoying but if you duplicate the say statement so that there's one immediately before, and inside a menu statement, then use the CPS tag to hard code the menu say statement to display the text instantly, you can have your 'typewritten' dialogue, with accoutrements, and also display a question at a menu. Here's an example.

Code: Select all

init python:

    def alter_say_strings( str_to_test ):
        str_map = {
            ". " : ". {w=0.75}", 
            ", " : ", {w=0.45}",
        }
        for key in str_map:
            str_to_test = str_to_test.replace( key, str_map[ key ] ) 
        return str_to_test

define config.say_menu_text_filter = alter_say_strings

"How do you like it, when you can fudge config.say_menu_text_filter to work in a menu?"
menu:
    "{cps=0}How do you like it, when you can fudge config.say_menu_text_filter to work in a menu?{/cps}"
    "I like it a lot.":
        "Superb! Enjoy!"
    "I like it somewhat.":
        "Oh. Well, I suppose that's good enough."

[The only bug is my reading comprehension]

Posted: Tue Apr 27, 2021 11:56 pm
by itoril
Okay, this is embarrassing. I've learned that there are no bugs here: The "w" tag only works in dialogue statements, and the menu statement doesn't count. So while config.say_menu_text_filter works with menus, the thing I'm doing with it doesn't. Meanwhile, the character callbacks example excludes the "interact" property, of which "menu" is.

I just haven't read the documentation/code closely enough. Thing is, I tried removing the "if not interact:" from the callback code and it bleeped in places I didn't want it to. So my previous post is still helpful for anyone who wants to fudge that for menu statements. You live and you learn. I'll probably favour posting in the "Questions and Announcements" subforum instead...