API ReferenceGE Extensionsflowgraphnodesutil
Random Number
- **Node Name:** `Random Number`
Overview
- Node Name:
Random Number - Category:
repeat_instant - File:
extensions/flowgraph/nodes/util/randomNumber.lua
Outputs a random number within a specified range each frame it receives flow. Supports both integer and floating-point output.
Pin Schema
Input Pins
| Pin | Type | Default | Description |
|---|---|---|---|
rangeStart | number | 0 | The smallest number in the range (hardcoded) |
rangeEnd | number | 10 | The biggest number in the range (hardcoded) |
float | bool | false | If enabled, output is a float; otherwise integer (hidden, hardcoded) |
Output Pins
| Pin | Type | Description |
|---|---|---|
random | number | The generated random number |
Internals
Key Methods
| Method | Description |
|---|---|
work() | Generates a random number between rangeStart and rangeEnd each frame |
Random Generation Logic
- Integer mode (default): Uses
math.random(rangeStart, rangeEnd)for whole numbers. - Float mode: Computes
rangeStart + math.random() * (rangeEnd - rangeStart)for continuous values. - Fallback: If start/end are nil, returns
math.random()(0 to 1).
How It Works
- Each frame,
work()checks ifrangeStartandrangeEndare provided. - Based on the
floatpin, selects integer or floating-point random generation. - Outputs the result on the
randompin. - Since the category is
repeat_instant, a new random number is generated every frame.
Usage Example
-- Integer random between 1 and 100:
-- rangeStart = 1, rangeEnd = 100, float = false
-- Output: 42 (varies each frame)
-- Float random between 0.0 and 1.0:
-- rangeStart = 0, rangeEnd = 1, float = true
-- Output: 0.73521... (varies each frame)
-- No range specified:
-- Both pins nil → output is math.random() (0 to 1)Key Dependencies
math.random()- Lua standard library random number generation
See Also
- Route Distance (Flowgraph Node) - Related reference
- Closest Road (Flowgraph Node) - Related reference
- Custom Lua (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide