Transform List (Effect) — Skript

Addon: Skript · Category: Effect · Since: 2.10

Syntax

(transform|map) %~objects% (using|with) <.+>

Description

Transforms (or 'maps') a list's values using a given expression. This is akin to looping over the list and setting each value to a modified version of itself. Evaluates the given expression for each element in the list, replacing the original element with the expression's result. 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. Only variable lists can be transformed with this effect. For other lists, see the transform expression.

Examples

set {_a::*} to 1, 2, and 3
transform {_a::*} using input * 2
# {_a::*} is now 2, 4, and 6
# get a list of the sizes of all clans without manually looping
set {_clan-sizes::*} to indices of {clans::*}
transform {_clan-sizes::*} using {clans::%input%::size}
# set all existing values of a list to 0:
transform {_list::*} with 0

View source