Skript icon indicating copy to clipboard operation
Skript copied to clipboard

Add EffSort, rework ExprInput to use ParserData

Open sovdeeth opened this issue 1 year ago • 4 comments

Description

This PR supersedes @Pikachu920's #6342 PR to be more generic and extendable. Syntaxes can now implement InputSource to declare themselves as valid sources of input for ExprInput.

This also adds input index as a pattern for ExprInput, which will allow the accessing of a value's index when filtering/sorting a variable list.

Also added is EffSort, an effect for sorting variable lists. This effect allows a custom expression to map the values before sorting, so lists can now be sorted in a somewhat custom manner. The sorting is still done with the natural ordering of the mapped values, so this does not current support custom comparators. If the custom expression has returns a null value at any point, the sort will be aborted and the list will remain the same, as null values cannot be compared. Alternatively, we could just strip out the invalid values, but I think that's a destructive failure state that could result in users losing valuable data if they make a small mistake.


Target Minecraft Versions: any Requirements: none Related Issues: #6715 #4327

sovdeeth avatar May 28 '24 18:05 sovdeeth

couldnt we do the sorting async?

Pikachu920 avatar Jun 01 '24 20:06 Pikachu920

couldnt we do the sorting async?

pikachu please you're killing me and yes I think so

sovdeeth avatar Jun 01 '24 20:06 sovdeeth

couldnt we do the sorting async?

@Pikachu920 we can do the actual sorting asynchronously, but we cannot ensure the expression is safe to evaluate asynchronously, so this would be of limited assistance. Do you think it's still worth adding?

sovdeeth avatar Jun 03 '24 20:06 sovdeeth

couldnt we do the sorting async?

@Pikachu920 we can do the actual sorting asynchronously, but we cannot ensure the expression is safe to evaluate asynchronously, so this would be of limited assistance. Do you think it's still worth adding?

yes please. I am imagining people will use this for things like "top" listings which might have a lot of elements to sort. I think you have pointed out a larger issue though. anything that uses asynceffect at the moment is probably calling getters async 😖

Pikachu920 avatar Jun 03 '24 20:06 Pikachu920