Transformed List (Expression) — Skript

Addon: Skript · Category: Expression · Since: 2.10

Syntax

%objects% (transformed|mapped) (using|with) \[<.+>\]

Description

Transforms (or 'maps') a list's values using a given expression. This is akin to looping over the list and getting a modified version of each value. If the given expression returns a single value, the indices of the list will not change. If the expression returns multiple values, then then indices will be reset as a single index cannot contain multiple values.

Examples

set {_a::*} to (1, 2, and 3) transformed using (input * 2 - 1, input * 2)
# {_a::*} is now 1, 2, 3, 4, 5, and 6
# get a list of the sizes of all clans without manually looping
set {_clan-sizes::*} to keyed {clans::*} transformed using [{clans::%input index%::size}]
# using the 'keyed' expression retains the indices of the clans list

View source