Scripting
Processing Numeric Values
With Peakboard, you can manipulate numbers in various ways. This template provides the following operations and functions:
- Floating-point random number
- Integer random number
- Addition
- Rounding
Floating-point Random Number
To generate a random floating-point number, use the following code:
data.Number = math.random(0, 99) + math.random()
Integer Random Number
To generate a random integer, use this code:
data.Number = math.random(-100, 100)
Addition
Addition can be performed as follows:
data.Number = data.Number + 2.65
Rounding
When rounding, you can choose between rounding to a whole number and rounding with decimal places.
To round to a whole number, use the following code:
data.Number = math.ceil(data.Number)
To round with decimal places, use this code:
data.Number = math.roundwithdecimals(data.Number, 1)