mirror of
https://github.com/1bardesign/batteries.git
synced 2024-11-22 06:04:35 +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.
|
"211", -- Unused local variable.
|
||||||
"212/self", -- Unused argument self.
|
"212/self", -- Unused argument self.
|
||||||
"213", -- Unused loop variable.
|
"213", -- Unused loop variable.
|
||||||
|
"214", -- used _ prefix variable (we use this often to indicate private variables, not unused)
|
||||||
"631", -- Line is too long.
|
"631", -- Line is too long.
|
||||||
},
|
},
|
||||||
files = {
|
files = {
|
||||||
|
12
mathx.lua
12
mathx.lua
@ -126,20 +126,20 @@ end
|
|||||||
--todo: more easings - back, bounce, elastic
|
--todo: more easings - back, bounce, elastic
|
||||||
|
|
||||||
--(internal; use a provided random generator object, or not)
|
--(internal; use a provided random generator object, or not)
|
||||||
local function _random(_r, ...)
|
local function _random(rng, ...)
|
||||||
if _r then return _r:random(...) end
|
if rng then return rng:random(...) end
|
||||||
if love then return love.math.random(...) end
|
if love then return love.math.random(...) end
|
||||||
return math.random(...)
|
return math.random(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
--return a random sign
|
--return a random sign
|
||||||
function mathx.random_sign(_r)
|
function mathx.random_sign(rng)
|
||||||
return _random(_r) < 0.5 and -1 or 1
|
return _random(rng) < 0.5 and -1 or 1
|
||||||
end
|
end
|
||||||
|
|
||||||
--return a random value between two numbers (continuous)
|
--return a random value between two numbers (continuous)
|
||||||
function mathx.random_lerp(min, max, _r)
|
function mathx.random_lerp(min, max, rng)
|
||||||
return mathx.lerp(min, max, _random(_r))
|
return mathx.lerp(min, max, _random(rng))
|
||||||
end
|
end
|
||||||
|
|
||||||
--nan checking
|
--nan checking
|
||||||
|
Loading…
Reference in New Issue
Block a user