<random>
Description
Sets the numbers that will be returned by the random
function of the JS API.
caution
This tag is mandatory if the
$jsapi.random
function is called in the script. If it is missing, the function will return 0
.In case more random numbers are requested in the script than defined in the <random>
tag, the $jsapi.random
function will return 0
.
If the smartRandom
field is not defined in the bot query, then $jsapi.random
is used to get random numbers when calling $reactions.random
. Duplicate numbers are ignored.
$reactions.random
is also used when selecting an option in the random
tag in scripts.
All random numbers generated during the test are stored in response
.
Body
List of numbers separated by a character ,
.
How to use
<random>1, 2, 3, 4, 5</random>
<random>
128, 0, 42
</random>
Consider the script:
theme: /
state: Random
q!: rand
random:
# Index 0
a: first!
# Index 1
a: second!
# Index 2
a: third!
Script test:
<test>
<test-case>
<random>1,2</random>
<q>rand</q>
<a>second!</a> <!-- Index 1 -->
<q>rand</q>
<a>third!</a> <!-- Index 2 -->
<q>rand</q>
<a>first!</a> <!-- Index 0 -->
</test-case>
</test>
Here:
$jsapi.random
returns1
, the response with index 1 is returned.$jsapi.random
returns2
, the response with index 2 is returned.$jsapi.random
returns0
, because the numbers defined in the<random>
tag have run out. The response with index 0 is returned.