Module:MOS genchain: Difference between revisions

Ganaram inukshuk (talk | contribs)
Period scale degrees for negative gen counts are shifted one period up
Ganaram inukshuk (talk | contribs)
bugfix for multiperiod mosses
Line 38: Line 38:


function p._mos_genchain(input_mos)
function p._mos_genchain(input_mos)
local input_mos = input_mos or mos.new(6, 4)
local input_mos = input_mos or mos.new(10,5)
local num_gens = mos.period_step_count(input_mos)
local num_gens = mos.period_step_count(input_mos)
Line 65: Line 65:
local num_gens = math.ceil(#genchain/2) - i
local num_gens = math.ceil(#genchain/2) - i
result = result .. string.format("| %s", num_gens)
result = result .. string.format("| %s", num_gens)
local current_interval = genchain[i]
local period_interval = mos.period(input_mos)
-- Scale degree (full name) and abbrev
-- Scale degree (full name) and abbrev
Line 75: Line 72:
-- If the scale degree is reached by a negative number of gens, then
-- If the scale degree is reached by a negative number of gens, then
-- say it's the degree one period up instead.
-- say it's the degree one period up instead.
current_interval = mos.interval_add(current_interval, mos.interval_mul(period_interval, j - 1))
local period_interval = mos.period(input_mos)
period_raised_interval = mos.interval_add(current_interval, period_interval)
local current_interval = mos.interval_add(genchain[i], mos.interval_mul(period_interval, j - 1))
local period_raised_interval = mos.interval_add(current_interval, period_interval)
if num_gens == 0 then
if num_gens == 0 then
result = result  
result = result