-
Notifications
You must be signed in to change notification settings - Fork 0
DataAt
The listutils:data_at function finds the element at an index.
Input is given using the listutils:in storage:
| Field | Meaning |
|---|---|
List |
The list that contains the index. |
Additionally, the index should be put in the $listutils.index listutils.in score. Negative indices will have the same behavior as using them in a static context.
After defining the input, run the function listutils:data_at.
Errors that display when executing the listutils:data_at function as a player in debug mode.
| Error | Message |
|---|---|
| TBD | TBD |
The success of the operation is stored in the $listutils.success listutils.out score. This score is 1 on success and 0 otherwise.
The result of the operation is stored inside the Data field in the listutils:out storage.
Take the example list ExampleList: ["foo", "Hello World!", "foo", "bar"] in the listutils:examples storage. We want to find the element at index 1:
# Add List to the input.
data modify storage listutils:in List set from storage listutils:examples ExampleList
# Add the index to the input.
scoreboard players set $listutils.index listutils.in 1
# Call the function.
function listutils:data_atThis would return "Hello World!" inside the Data field in the listutils:out storage.