Random numbers
Seeded random numbers that come out the same on every machine. math.random is not available.
mod.rng(seed)
Section titled “mod.rng(seed)”server + client
A generator. The same seed gives the same numbers on every machine, so co-op and replays agree.
| Parameter | Type | |
|---|---|---|
seed |
number |
Any number. |
Returns { next(), int(lo, hi), pick(list), chance(p) }: next() is 0 up to 1
local r = mod.rng(42)local pick = r.pick({ "frost", "lava", "desert" })if r.chance(0.5) then mod.log("heads", r.int(1, 6), pick)end