-
-
Notifications
You must be signed in to change notification settings - Fork 393
ExprCopy + CondCanCopy #7908
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
base: dev/feature
Are you sure you want to change the base?
ExprCopy + CondCanCopy #7908
Conversation
is there any major benefit to using the condition than always using |
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.
Just nit picks
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.
Great changes
A few concerns here
Can you elaborate why this was a problem? What issues were present, what did you need a copy for? I know it's kind of intended for item components, but if you have the components using a cloner, they'll be constantly copied whenever they're added to a variable regardless, which would cause some issues when using them. I think for this to actually be useful, it needs to copy things that don't normally get copied. You could do this via additions to the cloner like |
I have tests for ItemStack, Location and Vector for checking that the objects are actually separate. Unfortunately can't do it for BlockData because there is currently no generic blockdata modifier.
Although internally Skript already basically does this when setting a variable, users may not know nor realize this. By exposing this functionality, users can safely ensure themselves that they are indeed grabbing and modifying a copy. Plus with the addition of the condition, users can debug what and what can not be copied through Skript itself and possibly even attempt to make their own copies.
Including all things stated in the previous reply section. There was no way of getting a copy using an expression, and as you said, Skripts internal cloning usage would not be done for setting non variables. Sure the
Though not tested, I believe this would solely be the problem of the already existing functionality and not caused by my PR.
I can definitely add this to help mitigate the problem caused by Skript.
Truthfully, I wish you would've voiced these concerns when we were discussing it in Discord yesterday. |
Honestly I didn't have these concerns until I saw the feature as a whole, though i did mention the idea of having a cloner that's not normally used outside of an explicit copy syntax. Sorry if it feels like an about face, I didn't mean to mislead you or anything.
I'm still not really sure what problems it solves. I see two things so far:
I think trying to address those two is good, but I think that scope's a bit limiting and doesn't really help the end user much. I don't really ever see people trying to get help with copying thing and I struggle to see what actual use cases users need this for that I don't know, I'm not totally against this, I just am struggling to come up with any concrete scenarios where it'd be useful. The one case I can come up with is setting metadata doesn't set it to a clone, so there could be aliasing issues there, but that seems more a flaw in the metadata expression than something that should be solved by adding a copy expression. |
Problem
There was no expression to grab copies of objects.
There was no way to check if an object was copyable or not.
Solution
This PR adds
ExprCopy
allowing an expression usage of grabbing copies of objects.If an object can not be copied/cloned then that object will be excluded.
Alternatively, users can opt in to return the original object if it can not be copied, by adding
with fallback
This PR adds
CondCanCopy
allowing users to check if an object can be copied or not. Which would further help debugging and if they need to usewith fallback
when usingExprCopy
Testing Completed
ExprCopy.sk
andCondCanCopy.sk
Supporting Information
N/A
Completes: #7874
Related: none