Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match statements for dialogue #312

Open
IntangibleMatter opened this issue Oct 14, 2023 · 2 comments
Open

Match statements for dialogue #312

IntangibleMatter opened this issue Oct 14, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@IntangibleMatter
Copy link

Is your feature request related to a problem? Please describe.
In writing my dialogue, I frequently have dialogue that's based off of how many times you've talked to a character.
Currently the only way to write dialogue to work like this is by having long if/elif/else statements.

Describe the solution you'd like
Syntactic sugar over the if/else statement that lets you state the one variable you'd like to compare against at the start, followed by options for each of them, as an example.

match Chars.john_talk_count:
    0:
        John: Hey, nice to meet you!
    1:
        John: Hey, {{Chars.player_name}}, right? Good to see you again!
    2:
        John: Hey! I've already talked to you twice. Isn't that enough for now?
    _:
        John: {{Chars.player_name}}... please, we've talked {{Chars.john_talk_count}} times already... I need a break.
Chars.john_talk_count += 1

Which is way nicer and faster to write than:

if Chars.john_talk_count == 0:
    John: Hey, nice to meet you!
elif Chars.john_talk_count == 1:
    John: Hey, {{Chars.player_name}}, right? Good to see you again!
elif Chars.john_talk_count == 2:
    John: Hey! I've already talked to you twice. Isn't that enough for now?
else:
    John: {{Chars.player_name}}... please, we've talked {{Chars.john_talk_count}} times already... I need a break.
Chars.john_talk_count += 1

Describe alternatives you've considered
Just having a bunch of if statements that check the same property verbosely

Additional context
This would be a great addition for writing dialogue faster. It also means that if you want to change which variable is being checked, you only have to change the value in the match statement,

(please forgive me if this does exist, I'm new to using the plugin but I couldn't find this feature anywhere in the documentation)

@IntangibleMatter IntangibleMatter added the enhancement New feature or request label Oct 14, 2023
@nathanhoad
Copy link
Owner

I've been thinking of adding match statements but it's not a small task - it's definitely on the todo list but I'm not entirely sure how long before I'll get to it.

@IntangibleMatter
Copy link
Author

Noted, maybe I'll take a look at the parser and see if I can find a way to add them, save you a bit of work.

Repository owner deleted a comment from yawoffeh Feb 20, 2024
Repository owner deleted a comment from Obasoro Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants