Logo Anfibia Reactor ™ - User Guide
Copyright © 2013 Anfibia Software. All Rights Reserved.
www.anfibia-soft.com
Plugins : API : random

Summary

Generates a random value.

Syntax

local someRealNum = random()
local someInteger = random(maxNumber)
local someNumberInRange = random(minNumber, maxNumber)
local someValue = random(table)

Parameters

maxNumber : Integer number indicating the maximum value in the range.
minNumber : Integer number indicating the minimum value in the range.
table : Table containing the possible values.

Returns

Random value, depending on the parameters. See below for details.

Description

This function generates a random number by using Windows cryptographically secure pseudorandom number generator, and returns a value depending on the calling parameters.

Examples

local randomPercentage = random() * 100
local randomAge = random(99)
local randomIpAddress = '192.168.1.' .. random(1, 255)
local randomDay = random({'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'})
print('Percentage: ' .. randomPercentage .. '%')
print('Age: ' .. randomAge)
print('ip address: ' .. randomIpAddress)
print('Day of the week: ' .. randomDay)

Percentage: 87.224373774242%
Age: 45
ip address: 192.168.1.180
Day of the week: Wednesday