From 6e65f82474721e3f3f6ffe6ad2781f542e964637 Mon Sep 17 00:00:00 2001 From: Max Cahill <1bardesign@gmail.com> Date: Fri, 22 Apr 2022 10:05:44 +1000 Subject: [PATCH] clarified rng variable name, but also removed warning for _ prefixed variables as they are used to signal internal/private variables rather than unused variables. --- .luacheckrc | 1 + mathx.lua | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 1e5df27..a88280a 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -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 = { diff --git a/mathx.lua b/mathx.lua index 7afbbcc..502db21 100644 --- a/mathx.lua +++ b/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