Add mcl_util.float_random function to get reliable floating point random numbers

This commit is contained in:
cora 2024-08-20 06:29:04 +02:00
parent 16b07f2fb3
commit 53622c7339
No known key found for this signature in database

View File

@ -1433,3 +1433,12 @@ function mcl_util.detach_object(obj, change_pos, callback)
end, obj)
end
end
function mcl_util.float_random(from, to)
assert(tonumber(from), "[mcl_util] mcl_util.float_random called without valid(number) argument(s)")
if not to then
to = from
from = 1
end
return from + ( math.random() * ( to - from ))
end