mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-11-19 07:04:24 +00:00
added seed() fn, corrected err with local math_random
This commit is contained in:
parent
0eccde530a
commit
fb7b826942
@ -61,6 +61,11 @@ Given an `angle` and `magnitude`, returns a vector.
|
|||||||
local x, y = lume.vector(0, 10) -- Returns 10, 0
|
local x, y = lume.vector(0, 10) -- Returns 10, 0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### lume.seed([low [, high]])
|
||||||
|
Sets random seed. If using LOVE engine's math library, both `low` and `high`
|
||||||
|
arguments are used, else, only one argument is accepted.
|
||||||
|
|
||||||
|
|
||||||
#### lume.random([a [, b]])
|
#### lume.random([a [, b]])
|
||||||
Returns a random number between `a` and `b`. If only `a` is supplied a number
|
Returns a random number between `a` and `b`. If only `a` is supplied a number
|
||||||
between `0` and `a` is returned. If no arguments are supplied a random number
|
between `0` and `a` is returned. If no arguments are supplied a random number
|
||||||
|
8
lume.lua
8
lume.lua
@ -32,7 +32,8 @@ local math_ceil = math.ceil
|
|||||||
local math_atan2 = math.atan2 or math.atan
|
local math_atan2 = math.atan2 or math.atan
|
||||||
local math_sqrt = math.sqrt
|
local math_sqrt = math.sqrt
|
||||||
local math_abs = math.abs
|
local math_abs = math.abs
|
||||||
local math_random = love and love.math or math.random
|
local math_random = love and love.math and love.math.random or math.random
|
||||||
|
local math_randomseed = love and love.math and love.math.setRandomSeed or math.randomseed
|
||||||
|
|
||||||
local noop = function()
|
local noop = function()
|
||||||
end
|
end
|
||||||
@ -131,6 +132,11 @@ function lume.vector(angle, magnitude)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function lume.seed(low, high)
|
||||||
|
return math_randomseed(low, high)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function lume.random(a, b)
|
function lume.random(a, b)
|
||||||
if not a then a, b = 0, 1 end
|
if not a then a, b = 0, 1 end
|
||||||
if not b then b = 0 end
|
if not b then b = 0 end
|
||||||
|
Loading…
Reference in New Issue
Block a user