Improving the consistency of where filters #6060
Replies: 3 comments 5 replies
-
I like the () change, but i think the loop-value change is very confusing. |
Beta Was this translation helpful? Give feedback.
-
Also #4856 |
Beta Was this translation helpful? Give feedback.
-
I think this a great idea pikachu. I'm not particuarly happy with the filter syntax as-is and I always love it when we can do things better.
Sounds great, I'd love it if they could be optional but I think that could be hard on the parser unless we had some kind of detection.
I don't hugely love the loop-value syntax, but I do agree with moving away from teleport all players where (it has permission "my_permission") to {something}
set {_things::*} to {_items::*} where (it is a stone sword) |
Beta Was this translation helpful? Give feedback.
-
The existing where filter syntax in Skript is kind of odd. When I added it years ago, I just copied the lambda syntax from skquery and called it a day. This isn't great. The where filter is the only place in Skript that square brackets are used, so it's kinda confusing. In skquery, using square brackets made more sense because they represented a lambda object which had other uses. In skript, their only purpose is to help the parser understand which part of the expression is the condition. This brings me to my proposed changes to the where filter:
Proposed Changes
Like mentioned above, the square brackets are currently only used to help the parser differentiate the parts of the syntax. Skript already uses parentheses for this same purpose, so it would make more sense to just use parentheses here.
loop-value
instead ofinput
Skript already had an expression for a looped value. It would make more sense to reuse it instead of having a dedicated expression just for where filters. In addition, we could add support for loop-index when filtering variables.
input
and square brackets for eventual removalIf these proposals are implemented, input and square brackets can be deprecated for removal in a future release.
Potential issues
If we use
loop-value
instead ofinput
, one potential issue would be how loop-value numbering works. For example:The where filter has to use loop-value-2 since it's within a loop already and the nested loop has to use
loop-value-3
rather thanloop-value-2
due to the where filter. This might be a pain to implement or confusing to users.Before/after examples
set {_admins::*} to all players where [input has permission "admin"]
->set {_admins::*} to all players where (loop-value has permission "admin")
kill all pigs where [name of input is "unlucky pig"]
->kill all pigs where (name of loop-value is "unlucky pig")
Beta Was this translation helpful? Give feedback.
All reactions