-
Notifications
You must be signed in to change notification settings - Fork 759
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
Return objects from events based extensions #3163
base: master
Are you sure you want to change the base?
Conversation
Finally getting to this! Very interesting! Is this supporting a few interesting use cases like objects created in the function, can you return them? |
Yep! You can test it with this project file: pikk.zip |
I've identified multiple edge cases. This is not an easy problem, this can be very powerful but we must be sure that we handle everything properly and be 100% correct so that we don't discover later issues when using groups/passing groups/passing multiple objects/calling this action multiple times :) I think the key is being very clear about what is inside the object lists. |
Whoops! While I indeed tested passing groups, I did not test for those edge cases. I fixed the first and second one, though I am not sure I understand the last one. If the object is passed twice, shouldn't modifying its picked objects still be fine? The only other alternative would be to not pick them but that sounds more confusing. |
I think I understand now what you meant with that last edge case (what if i am using a group in the function that consists of two times the same object that was passed?), and my current implementation while being a little slower on that edge case should be resilient against this (e.g. it will not duplicate objects in the list, since even if it fills it a second time it will clear it before doing so). As the edge cases seem fixed, I am removing the draft. |
Ping! |
1 similar comment
Ping! |
.AddAction("SetReturnObject", | ||
_("Set object return value"), | ||
_("Returns the currently selected objects. Those objects will be the ones selected for the next actions, conditions, subevents etc."), | ||
_("Set objects to return to _PARAM0_"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably find a name that implies that we're not really "returning" anything but rather "pick objects PARAM0 as the result of this condition"?
(speaking of which, this should usually only happen in a condition, even if in theory actions can also use this).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I named it return because I think that is both more useful and intuitive. This action also sets the return value to true, so it does return "something". The logic behind it is that if you have no objects to pick, then a previous condition had 0 objects so it should be false, so you are not returning any objects and want your condition not to be true either. If you did pick objects in your previous conditions, then you change the picked objects and want the condition to return true since some objects are picked.
Sorry about the delay on this, it's hard to review because I'm not sure if we're missing a case or not.
|
I added some cases in the example project: I observed that:
|
To answer my younger self:
This is actually not a real use-case because behavior Object picking is handled by the generated code according to returned boolean from the condition already.
The issue was the use of It will work for simple picking but the events may need to use imbricated "for each instance" to check some conditions on each object tuples. It won't be possible with just this new action. Maybe, it could require a new concept like named picking list:
The idea would be to build an object list in "for each instance" loops and use the condition to get the result and give it to the "Return" action. Something like this:
Though, it would be better if we can found a simpler solution. |
This adds an action to return objects from an events based extension. This will set the return value to true and pick the currently picked instances of the object back to where the function is used.
Example:
pick.zip