tm.random
Random text and numbers. Shared.
lua
local code = tm.random.getRandomText(8, tm.random.upperCase, tm.random.numbers) -- 'K3Q9ZT7B'
local n = tm.random.getRandomIntInRange(1, 6) -- 1 to 6, both included
local f = tm.random.getRandomFloatInRange(0.5, 1.5) -- 0.5 up to (not including) 1.5| Name | Notes |
|---|---|
upperCase, lowerCase, numbers, symbols | Character set strings to pass to getRandomText. |
getRandomText(length, ...) | Picks length characters from the sets you pass. Returns '' for a length below 1 or when no sets are given. |
getRandomIntInRange(min, max) | Both ends included. |
getRandomFloatInRange(min, max) | Includes min, excludes max. |
Built on math.random, seeded once when the import loads (the server mixes in os.time, the client uses the game timer). This is fine for codes, plates and picks. It is not cryptographically secure: never use it for tokens or secrets.
The generator is seeded once, so calls close together are not correlated.