Module:MOS mode degrees: Difference between revisions

ArrowHead294 (talk | contribs)
mNo edit summary
Ganaram inukshuk (talk | contribs)
Todo; to distinguish this from mos modes and to follow with current usage of mos mode names, this template will no longer display mode names and mos modes will be used for displaying names
Line 4: Line 4:
local yesno = require("Module:Yesno")
local yesno = require("Module:Yesno")
local p = {}
local p = {}
-- TODO
-- - Split off modmos mode degrees as a separate template


-- Global variables for cell colors
-- Global variables for cell colors
Line 53: Line 56:
-- Create a table of a mos's degrees
-- Create a table of a mos's degrees
-- If a step pattern is provided, it's assumed to be that of a modmos
-- If a step pattern is provided, it's assumed to be that of a modmos
function p._mos_mode_degrees(input_mos, mos_prefix, mode_names, use_default_mode_names, is_collapsed, step_pattern)
function p._mos_mode_degrees(input_mos, mos_prefix, is_collapsed, step_pattern)
local is_true_mos = step_pattern == nil
local is_true_mos = step_pattern == nil
local input_mos = input_mos or mos.new(5, 2)
local input_mos = input_mos or mos.new(5, 2)
local mos_prefix = mos_prefix or "mos"
local mos_prefix = mos_prefix or "mos"
local is_collapsed = is_collapsed == true
local is_collapsed = is_collapsed == true
-- If default mode names are to be used, they'll overwrite whatever mode names are passed in, even if there aren't any
local mode_names = mode_names or nil
local use_default_mode_names = use_default_mode_names == true
-- Get the modes as strings and step vectors
-- Get the modes as strings and step vectors
Line 88: Line 87:
udps = tamnams.mos_mode_udps(input_mos)
udps = tamnams.mos_mode_udps(input_mos)
cpos = tamnams.mos_mode_cpos(input_mos)
cpos = tamnams.mos_mode_cpos(input_mos)
-- Produce default mode names if needed
if use_default_mode_names then
local default_mode_names = {}
for i = 1, #udps do
table.insert(default_mode_names, string.format("%s %s", scale_sig, udps[i]))
end
mode_names = default_mode_names
end
else
else
-- Modmos udps require a mosabbrev; this is forced to be "m" since some
-- Modmos udps require a mosabbrev; this is forced to be "m" since some
Line 112: Line 102:
end
end
table.insert(cpos, i)
table.insert(cpos, i)
end
-- Produce default mode names if needed
if use_default_mode_names then
local default_mode_names = {}
for i = 1, #udps_closest_bright do
if udps_closest_bright[i] == udps_closest_dark[i] then
table.insert(default_mode_names, string.format("%s %s", scale_sig, udps_closest_bright[i]))
else
table.insert(default_mode_names, string.format("%s %s<br>%s %s", scale_sig, udps_closest_bright[i], scale_sig, udps_closest_dark[i]))
end
end
mode_names = default_mode_names
end
end
end
end
Line 143: Line 120:
.. "!! rowspan=\"2\" | Rotational<br>Order "
.. "!! rowspan=\"2\" | Rotational<br>Order "
.. "!! rowspan=\"2\" | Step<br>Pattern"
.. "!! rowspan=\"2\" | Step<br>Pattern"
-- Add mode names if present
if mode_names_given then
result = result .. " !! rowspan=\"2\" class=\"unsortable\" | Mode<br>Names"
end
-- Add header for scale degrees
-- Add header for scale degrees
Line 167: Line 139:
-- Add brightness order (as UDP), rotational order, and step pattern
-- Add brightness order (as UDP), rotational order, and step pattern
.. string.format("| %s || %s || %s", udps[i], cpos[i], step_patterns[i])
.. string.format("| %s || %s || %s", udps[i], cpos[i], step_patterns[i])
 
-- Add mode name if given
if mode_names_given then
result = result .. string.format(" || %s", mode_names[i])
end
-- Add scale degrees with cell coloring
-- Add scale degrees with cell coloring
for j = 1, #step_matrices[i] do
for j = 1, #step_matrices[i] do
Line 319: Line 286:
local result = ""
local result = ""
if step_pattern == "" then
if step_pattern == "" then
result = p._mos_mode_degrees(input_mos, mos_prefix, mode_names, use_default_names, is_collapsed)
result = p._mos_mode_degrees(input_mos, mos_prefix, is_collapsed)
--elseif #step_pattern == input_mos.nL + input_mos.ns then
--elseif #step_pattern == input_mos.nL + input_mos.ns then
else
else
result = p._mos_mode_degrees(input_mos, mos_prefix, mode_names, use_default_names, is_collapsed, step_pattern)
result = p._mos_mode_degrees(input_mos, mos_prefix, is_collapsed, step_pattern)
end
end