-
Notifications
You must be signed in to change notification settings - Fork 0
Filter functions
Filter functions can be used in the filter operation to filter a list.
A filter function can be specified using the $listutils.function listutils.in
score. This score corresponds to the ID of the function.
By default, there is currently one filter function in the List Utils datapack. This is located in the listutils.custom/functions/filter/functions/built_in
directory:
ID | Function | Description |
---|---|---|
0 | filter_data_get |
Filters elements according to their data get value. |
NOTE: IDs 0 to 99 should be reserverd for filter functions native to the List Utils datapack, in case more functions are included in the future.
Users can create custom filter functions for their own needs. These functions should adhere to the return values below. For more information, see the Custom functions page.
The data element to filter is located in the In
field in the listutils:filter
storage. The current index of the iteration is stored in the $listutils.current_index listutils.in
score.
The return value should be stored in the $listutils.filter listutils.out
score.
The filter function should return 0
when the element should not be included in the filtered list. All other values will be treated as if the element should be included in the filtered list.