Allow expressions to return variables #2548
Replies: 1 comment
-
|
Short answer is: Yes we could rework the extensions so that expressions of type For your example though, you could (and should) expose easy to use expressions/actions for the most common use case, and as you're saying also a way to actually set or get the entire array from a variable (so you give a escape hatch for more complex manipulations, without complexifying your interface). That sounds like a sensible design I think :) But having expressions returning variables would help for extensions/behaviors holding complex structures. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The problem:
Let's say I have a "command" behavior for text input objects that splits words by space into an array. How would I let the user access the array of words? I could make a GetArgument(index) expression, but maybe I want to get the user get the amount of arguments, or modify the arguments... And end up re-implementing an array :p. Another possibility would be making an action to set a scene variable to the computed array. That is pretty verbose and not the most intuitive though :/
The solution:
Why not just return the array directly? The user would use it this way:
VariableString(Object.Command::GetArguments()[0]), orFor each child of Object.Command::GetArguments() do {}...This is IMO the most intuitive way, less verbose and is less work for extension developers B)
Beta Was this translation helpful? Give feedback.
All reactions