mirror of
https://github.com/1bardesign/batteries.git
synced 2024-11-10 02:31:48 +00:00
clarified rng variable name, but also removed warning for _ prefixed variables as they are used to signal internal/private variables rather than unused variables.
This commit is contained in:
parent
cb3083bc79
commit
6e65f82474
@ -4,6 +4,7 @@ return {
|
||||
"211", -- Unused local variable.
|
||||
"212/self", -- Unused argument self.
|
||||
"213", -- Unused loop variable.
|
||||
"214", -- used _ prefix variable (we use this often to indicate private variables, not unused)
|
||||
"631", -- Line is too long.
|
||||
},
|
||||
files = {
|
||||
|
12
mathx.lua
12
mathx.lua
@ -126,20 +126,20 @@ end
|
||||
--todo: more easings - back, bounce, elastic
|
||||
|
||||
--(internal; use a provided random generator object, or not)
|
||||
local function _random(_r, ...)
|
||||
if _r then return _r:random(...) end
|
||||
local function _random(rng, ...)
|
||||
if rng then return rng:random(...) end
|
||||
if love then return love.math.random(...) end
|
||||
return math.random(...)
|
||||
end
|
||||
|
||||
--return a random sign
|
||||
function mathx.random_sign(_r)
|
||||
return _random(_r) < 0.5 and -1 or 1
|
||||
function mathx.random_sign(rng)
|
||||
return _random(rng) < 0.5 and -1 or 1
|
||||
end
|
||||
|
||||
--return a random value between two numbers (continuous)
|
||||
function mathx.random_lerp(min, max, _r)
|
||||
return mathx.lerp(min, max, _random(_r))
|
||||
function mathx.random_lerp(min, max, rng)
|
||||
return mathx.lerp(min, max, _random(rng))
|
||||
end
|
||||
|
||||
--nan checking
|
||||
|
Loading…
Reference in New Issue
Block a user