Lua 5.1 already provides a built-in pseudo-random number generator through the `math` library.
Available functions:
```lua
math.random()
```
Returns a pseudo-random floating-point number between `0` and `1`.
```lua
math.random(max)
```
Returns a pseudo-random integer between `1` and `max`.
Example:
```lua
local number = math.random(100)
print(number) -- 1-100
```
You can also specify both the minimum and maximum value:
```lua
math.random(min, max)
```
Example:
```lua
local number = math.random(10, 50)
print(number) -- 10-50
```
It's also recommended to initialize the random seed once when the script starts:
```lua
math.randomseed(os.time())
```
Full example:
```lua
math.randomseed(os.time())
local randomNumber = math.random(1, 100)
print("Random number: " .. randomNumber)
```
So unless there is a specific reason to implement a custom random number generator, Lua 5.1's built-in `math.random()` should be enough for most gameplay/script purposes.
Available functions:
```lua
math.random()
```
Returns a pseudo-random floating-point number between `0` and `1`.
```lua
math.random(max)
```
Returns a pseudo-random integer between `1` and `max`.
Example:
```lua
local number = math.random(100)
print(number) -- 1-100
```
You can also specify both the minimum and maximum value:
```lua
math.random(min, max)
```
Example:
```lua
local number = math.random(10, 50)
print(number) -- 10-50
```
It's also recommended to initialize the random seed once when the script starts:
```lua
math.randomseed(os.time())
```
Full example:
```lua
math.randomseed(os.time())
local randomNumber = math.random(1, 100)
print("Random number: " .. randomNumber)
```
So unless there is a specific reason to implement a custom random number generator, Lua 5.1's built-in `math.random()` should be enough for most gameplay/script purposes.