Module:Infobox MOS: Difference between revisions

Ganaram inukshuk (talk | contribs)
m nocat -> debug, per clarified use for debug
Ganaram inukshuk (talk | contribs)
tuning -> input_mos; scalesig entered is processed as a mos and back to string to ensure it's formatted correctly for the infobox title (trying the long string first)
Line 37: Line 37:
-- Helper function
-- Helper function
-- Adds categories
-- Adds categories
function p.categorize(tuning)
function p.categorize(input_mos)
local tuning = tuning or "5L 2s"
local input_mos = input_mos or mos.new(5,2)
local input_mos = mos.parse(tuning)
-- Add to category of abstact mosses
-- Add to category of abstact mosses
Line 389: Line 388:


-- New "main" function
-- New "main" function
function p._infobox_mos(tuning, other_names_unparsed)
function p._infobox_mos(input_mos, other_names_unparsed)
local tuning = tuning or "5L 2s"
local input_mos = input_mos or mos.new(4,5,3)
local other_names_unparsed = other_names_unparsed or ""
local other_names_unparsed = other_names_unparsed or ""
local tuning_parsed = mos.parse(tuning)
local other_names_parsed = tip.parse_entries(other_names_unparsed) or tip.parse_entries(other_names_unparsed, ",")
local other_names_parsed = tip.parse_entries(other_names_unparsed) or tip.parse_entries(other_names_unparsed, ",")
Line 399: Line 397:
-- Keyboard visualization
-- Keyboard visualization
local kb_vis = p.kb_vis(tuning_parsed)
local kb_vis = p.kb_vis(input_mos)
p.concatenate_tables(sections, kb_vis)
p.concatenate_tables(sections, kb_vis)
-- Scale structure section
-- Scale structure section
local scale_structure = p.scale_structure(tuning_parsed)
local scale_structure = p.scale_structure(input_mos)
p.concatenate_tables(sections, scale_structure)
p.concatenate_tables(sections, scale_structure)
Line 411: Line 409:
-- Generator sizes section
-- Generator sizes section
local gen_sizes = p.generator_sizes(tuning_parsed)
local gen_sizes = p.generator_sizes(input_mos)
p.concatenate_tables(sections, gen_sizes)
p.concatenate_tables(sections, gen_sizes)
-- Tamnams info section, if applicable
-- Tamnams info section, if applicable
local tamnams_info = p.tamnams_information(tuning_parsed)
local tamnams_info = p.tamnams_information(input_mos)
if tamnams_info ~= nil then
if tamnams_info ~= nil then
p.concatenate_tables(sections, tamnams_info)
p.concatenate_tables(sections, tamnams_info)
Line 427: Line 425:
-- Related scales section
-- Related scales section
local related_scales = p.related_scales(tuning_parsed)
local related_scales = p.related_scales(input_mos)
p.concatenate_tables(sections, related_scales)
p.concatenate_tables(sections, related_scales)
-- Equal tunings section
-- Equal tunings section
local equal_tunings = p.equal_tunings(tuning_parsed)
local equal_tunings = p.equal_tunings(input_mos)
p.concatenate_tables(sections, equal_tunings)
p.concatenate_tables(sections, equal_tunings)


-- Adjacent links
-- Adjacent links
local adjacent_links = p.adjacent_links(tuning_parsed)
local adjacent_links = p.adjacent_links(input_mos)
local args = {
local args = {
["Adjacent Links"] = adjacent_links,
["Adjacent Links"] = adjacent_links,
["Title"] = tuning,
["Title"] = mos.as_long_string(input_mos),
["Rows"] = sections,
["Rows"] = sections,
}
}
Line 452: Line 450:
-- "Scale Signature" is preferred; "Tuning" is supported for legacy purposes
-- "Scale Signature" is preferred; "Tuning" is supported for legacy purposes
local tuning = args["Tuning"] or args["Scale Signature"]
local unparsed = args["Tuning"] or args["Scale Signature"]
local input_mos = mos.parse(unparsed)
local other_names = args["othernames"] or nil
local other_names = args["othernames"] or nil
local debug_mode = yesno(args["debug"], false)
local debug_mode = yesno(args["debug"], false)
local result = p._infobox_mos(tuning, other_names)
local result = p._infobox_mos(mos.as_long_string(input_mos), other_names)
if not debug_mode then
if not debug_mode then
result = result .. p.categorize(tuning)
result = result .. p.categorize(input_mos)
end
end