Module:MOS mode degrees: Difference between revisions

Ganaram inukshuk (talk | contribs)
double-flats
Ganaram inukshuk (talk | contribs)
Adopt verify function
Line 192: Line 192:
-- Function to be called as part of a template
-- Function to be called as part of a template
function p.mos_mode_degrees(frame)
function p.mos_mode_degrees(frame)
-- Default param for input mos is 5L 2s
-- Get args
local input_mos = mos.parse(frame.args["Scale Signature"]) or mos.new(2, 5, 2)
local input_mos   = mos.parse(frame.args["Scale Signature"])
local mos_prefix  = frame.args["MOS Prefix"]
local step_pattern = frame.args["MODMOS Step Pattern"]
local mode_names_unparsed = frame.args["Mode Names"]
-- Get the scale sig; for calculating the mos prefix
-- Get the scale sig; for calculating the mos prefix
local scale_sig = mos.as_string(input_mos)
local scale_sig = mos.as_string(input_mos)
-- Default param for mos prefix
-- Verify mosprefix
-- If "NONE" is given, no prefix will be used
mos_prefix = tamnams.verify_prefix(input_mos, mos_prefix)
-- If left blank, try to find the appropriate mos prefix, or else defualt to "mos"
-- If not left blank, use the prefix passed in instead
local mos_prefix = "mos"
if frame.args["MOS Prefix"] == "NONE" then
mos_prefix = ""
elseif string.len(frame.args["MOS Prefix"]) == 0 then
mos_prefix_lookup = tamnams.lookup_prefix(input_mos) or ""
if string.len(mos_prefix_lookup) ~= 0 then
mos_prefix = mos_prefix_lookup
end
else
mos_prefix = frame.args["MOS Prefix"]
end
-- Get the step pattern
local step_pattern = frame.args["MODMOS Step Pattern"]
-- Get the mode names
-- Get the mode names
Line 315: Line 302:
-- If using default mode names (scalesig+udp), those names are auto-added by the relevant function
-- If using default mode names (scalesig+udp), those names are auto-added by the relevant function
local use_default_names = false
local use_default_names = false
if #frame.args["Mode Names"] ~= 0 then
if #mode_names_unparsed ~= 0 then
if frame.args["Mode Names"] == "Default" then
if mode_names_unparsed == "Default" then
use_default_names = true
use_default_names = true
else
else
mode_names = tip.parse_entries(frame.args["Mode Names"])
mode_names = tip.parse_entries(mode_names_unparsed)
end
end
end
end