-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Support returning functions in match
patterns
#2337
Comments
Try this instead: match tr($Label.text):
"foo":
print("hi")
"bar":
print("ha") The values of |
I tried and it did not work which also surprised me. |
What you wrote makes that if the Label's text is "MY TEXT.", it will check if there's a translation with the key "MY TEXT." instead of checking for the translation. |
@MaaaxiKing Out of curiosity, what's the end goal here? What are you trying to achieve? |
I have a tutorial and there's text to display. Everytime the user does what he has to, I call |
I think you should have a separate variable that stores the untranslated text key at all times and use that for the |
i fully support this. it seems incredibly weird not to be able to use anything in a match statement that isn't a constant. it has hugely limited my code. i keep running into this over and over again. can't use variables as a pattern? this is silly. you should easily be able to compare a string with a bunch of different node names that vary because you have no idea what those names will be. if if statements can do it, there's no reason a match statement shouldn't also be able to. |
maybe this is the reason variables can no longer be used in match statements in 4.0. setters and getters return the value, and have been linked with declaration of variables. the loss of the ability to use variables in match statements is way to huge a loss imo not to reconfigure match to allow returning values for comparison. |
Describe the project you are working on
Reaction game
Describe the problem or limitation you are having in your project
I cannot check for a text with
tr()
inmatch
.Describe the feature / enhancement and how it helps to overcome the problem or limitation
You could use any function that returns something as a pattern in a match statement.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
If this enhancement will not be used often, can it be worked around with a few lines of script?
No
Is there a reason why this should be core and not an add-on in the asset library?
Yes, it's useful for everyone and not even possible to implement with an asset afaik.
The text was updated successfully, but these errors were encountered: