2024-12-11 05:32:24 +00:00
|
|
|
-- by Sovereignty
|
|
|
|
|
|
|
|
local module = {}
|
|
|
|
|
|
|
|
local rangesRNG = Random.new()
|
|
|
|
|
|
|
|
--[[
|
|
|
|
Produces a number range of integers regardless of if the input values are floats.
|
|
|
|
]]
|
|
|
|
function module.new(n1: number, n2: number): { Values: { number }, Random: (self: {}) -> (number) }
|
|
|
|
local ranges: {number} = {}
|
|
|
|
print(n1, n2)
|
|
|
|
local first = math.min(n1, n2)
|
|
|
|
local last = math.max(n1, n2)
|
2024-12-11 05:54:16 +00:00
|
|
|
for index = math.floor(first), math.floor(last + 1) do
|
2024-12-11 05:32:24 +00:00
|
|
|
table.insert(ranges, index)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function random(): number
|
|
|
|
local randomRange = ranges[rangesRNG:NextInteger(1, #ranges)]
|
|
|
|
warn(randomRange)
|
|
|
|
return randomRange
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
Values = ranges,
|
|
|
|
Random = random
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
return module
|