WeightedList - Random Element (Expression) — SkBee

Addon: SkBee · Category: Expression · Since: 3.24.0

Syntax

[%-number%] random weighted element[s] (of|from) %weightedlist%

Description

Returns a random element from the provided weighted list. Optionally you can include an amount of multiple random weighted elements from the list.

Examples

set {_loot} to new weighted list
add 1 of salmon to {_loot} with weight 5
add 1 of cod to {_loot} with weight 7
add stone sword of unbreaking 3 to {_loot} with weight 1
add 3 of cooked chicken to {_loot} with weight 2
add 4 of string to {_loot} with weight 15
set {_random} to random weighted element of {_loot}
set {_random::*} to 5 random weighted elements of {_loot}

View source