Open ch0m5 opened 1 month ago
As a use case, on a Node I'm building, whenever the focus of the TextEdit is lost, I want to verify the contents based on certain context, but I didn't find an easy way to "access" the var list from a Node so I could parse the variables or check if they exist at all.
Ideally, I'd want access to two methods:
A. get_invalid_vars(str: String)
, which would return an Array[String]
of all vars that cannot be parsed (if Array is empty, all is well).
B. parse_vars(str: String)
which would return the given String
with all vars parsed (according to the DialogueData we are operating Nodes on).
Having these, or similar methods available, allows me to warn the user that they're making a mistake the moment they make it. This is how the code looks like for this:
This being present for all Nodes where variables can be used would be ideal, as it would minimize the chance of unexpected behaviors.
Another note: while the Console error log is useful, changing the background of the text that's wrong to red is very visual and quite helpful too. If possible, I'd add both so that there's a "standard Node behavior" where anything that's painted red is going to fail or cause unexpected behavior if the dialogue runs.
In the sample below, I have very specific data types that need to be used, but this feature could be present at a general level for Nodes, most likely for variable usage. In other cases, such as the ConditionNode, you could pop similar errors (or warnings) if you compare a String
to an int
, for example.
https://github.com/user-attachments/assets/837f162a-2158-4b28-880b-bf6bdda77300
Problem
Whenever you use variables in Nodes, since it is done through Strings, typos can easily occur, which can lead to trying to access a variable that does not exist or similar unexpected behaviors.
Proposed Solution
Modify existing Nodes so that wherever variables can be used, the contents are checked for the presence of variables, and if so, it is checked that said variables exist in the DialogueData being edited and prompt an error otherwise.
Expected Behavior
For example, if a Dialogue, Fork, or Condition Node use a variable, the moment i "unfocus" the UI element that I'm editing, the contents are checked for variable presence, and if so, the system verifies the existence of variables with such a name or prompt an error otherwise.
It would be ideal if Nodes where bound, via signals or some similar method, to the DialogueNodes editor, so that whenever it is needed, the "Variable List" can be checked to return if a variable exists and ideally type it is as well. This could prove useful for Conditions or Method Calls, as you may be using a variable that is a
bool
in a context where aString
orint
is expected, so you can check while editing and prompt an warning/error to the user.