Skip to content

randompickstring

Daedalus1400 edited this page May 18, 2017 · 1 revision

Description:

The randompick generic picks randomly from a specified list. This page details usage for strings.

Added in release version 0.4.0

Arguments:

type

Must be "randompick".

text

Accepts an array of either strings or weighted strings. Mixing is allowed. Weighted strings are JSON Objects with the format

{"string": "your text here", "weight": 3}

Both arguments are required. Weights are relative to the other weights specified, so a weight of 2 will be picked twice as often as a weight of 1. Specifying three weighted strings with weights 1, 2, and 3 would produce the same relative frequency as using weights 10, 20, and 30.
Literal strings are given a weight of 1.

Example Usage:

The following example randomly writes one of four messages to the player's chat, with "text0" twice as likely to be picked as each of the others:

{"type": "chat", "message": {"type": "randompick", "text": [{"string": "text0", "weight": 2}, "text1", "text2", "text3"]}}
Clone this wiki locally