Skript
Skript copied to clipboard
Changes CondCompare to be able to directly compare two AND lists.
Description
Currently, the only way to compare two lists for exact equality is to check each element individually within a loop. Attempting to do 1, 2, 3 is 1, 2, 3
will always fail, because Skript compares lists by comparing each element in A to every element in B. This is great for most comparisons, like >, is between, or when using OR lists like 1, 2 is 1, 2, or 3
.
This PR adds a special case when comparing two AND lists for equality only which will compare each element to its corresponding position in the other list. This allows users to directly compare lists without having to manually loop.
Caveats:
- If you have lists with different indices,
{indexed by name::*} = {indexed by number::*}
will return true if the values are the same (and the same order). I think this is fine, personally. - 1, 2, 3 does not equal 3, 2, 1 with this PR. I also think this makes sense, but it may trip users up. Contains should be used to check that.
This is technically a breaking change, and I'm marking as such (and as enhancement), but I think it could be argued that there's no useful behavior this is breaking and it should be treated as a bug fix instead. We'd have to have a consensus on that, though.
Let me know opinions on or concerns about this change, or any suggestions!
This also adds more tests for CondCompare, but is by no means exhaustive.
Target Minecraft Versions: any Requirements: none Related Issues: #6293