diff --git a/init.lua b/init.lua index 15cec17..f23159c 100644 --- a/init.lua +++ b/init.lua @@ -349,7 +349,15 @@ local analyze_noiseparams = function(noiseparams) -- Calculate the two possible extreme values -- with the octave value being either at 1 or -1. local limit1 = (1 * np.persistence ^ exp) - local limit2 = (-1 * np.persistence ^ exp) + local limit2 + if not is_absolute then + limit2 = (-1 * np.persistence ^ exp) + else + -- If absvalue is set, one of the + -- limits is always 0 because we + -- can't get lower. + limit2 = 0 + end -- To add to the maximum, pick the higher value if limit1 > limit2 then @@ -357,15 +365,12 @@ local analyze_noiseparams = function(noiseparams) else o_max = o_max + limit2 end - if not is_absolute then - -- To add to the minimum, pick the LOWER value - if limit1 > limit2 then - o_min = o_min + limit2 - else - o_min = o_min + limit1 - end - -- Note: If absvalue flag is set, the sum of the octaves - -- is always 0, so we don't need to calculate it + + -- To add to the minimum, pick the LOWER value + if limit1 > limit2 then + o_min = o_min + limit2 + else + o_min = o_min + limit1 end end -- Add offset and scale to min/max value (final step)