Skip to content

Filter functions

PeerHeer edited this page Dec 31, 2019 · 2 revisions

Description

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.

Default functions

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.

Custom functions

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.

Parameters

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.

Return values

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.

Clone this wiki locally