Module:MOS modes: Difference between revisions
ArrowHead294 (talk | contribs) m Wait Tag: Undo |
ArrowHead294 (talk | contribs) m Try this Tag: Undo |
||
| Line 1: | Line 1: | ||
local mos = require( | local mos = require("Module:MOS") | ||
local rat = require( | local rat = require("Module:Rational") | ||
local utils = require( | local utils = require("Module:Utils") | ||
local tip = require( | local tip = require("Module:Template input parse") | ||
local p = {} | local p = {} | ||
| Line 44: | Line 44: | ||
-- Make a table with a column for the mode (as a string of L's and s's) and UDP | -- Make a table with a column for the mode (as a string of L's and s's) and UDP | ||
local result = | local result = "{| class=\"wikitable sortable\"\n" | ||
.. "|+ style=\"font-size: 105%;\" | Modes of " .. mos.as_string(input_mos) .. "\n" -- To create the scale signature with〈〉instead of <> | |||
.. "|-\n" | |||
.. "! [[UDP]] !! Rotational order !! Step pattern" | |||
-- If there are mode names (if the mode names array is not nil), then add a column for mode names | -- If there are mode names (if the mode names array is not nil), then add a column for mode names | ||
if #mode_names == #mos_modes then | if #mode_names == #mos_modes then | ||
result = result .. | result = result .. " !! class=\"unsortable\" | Mode names" | ||
end | end | ||
| Line 60: | Line 58: | ||
if add_columns then | if add_columns then | ||
for i = 1, #headers do | for i = 1, #headers do | ||
result = result .. | result = result .. " !! class=\"unsortable\" | " .. headers[i] | ||
end | end | ||
end | end | ||
result = result .. "\n" | |||
-- Enter each row | -- Enter each row | ||
| Line 78: | Line 78: | ||
local udp_as_text = "" | local udp_as_text = "" | ||
if periods == 1 then | if periods == 1 then | ||
udp_as_text = gens_up .. | udp_as_text = gens_up .. " {{!}} " .. gens_down | ||
else | else | ||
udp_as_text = gens_up .. | udp_as_text = gens_up .. " {{!}} " .. gens_down .. "(" .. periods .. ")" | ||
end | end | ||
result = result .. "|" .. udp_as_text | result = result .. "| " .. udp_as_text | ||
-- Add the mode's rotational order | -- Add the mode's rotational order | ||
local bright_gens_up = mossteps_per_bright_gen * (i-1) | local bright_gens_up = mossteps_per_bright_gen * (i - 1) | ||
local rotational_order = bright_gens_up % mossteps_per_period + 1 | local rotational_order = bright_gens_up % mossteps_per_period + 1 | ||
result = result .. "|" .. rotational_order | result = result .. " || " .. rotational_order | ||
-- Add the mode's step pattern | -- Add the mode's step pattern | ||
result = result .. "|" .. mos_modes[i] | result = result .. " || " .. mos_modes[i] | ||
-- Add the mode's name, if given | -- Add the mode's name, if given | ||
if #mode_names == #mos_modes then | if #mode_names == #mos_modes then | ||
result = result .. "|" .. mode_names[i] | result = result .. " || " .. mode_names[i] | ||
end | end | ||
| Line 101: | Line 101: | ||
for j = 1, #headers do | for j = 1, #headers do | ||
local index = (i - 1) * #headers + j | local index = (i - 1) * #headers + j | ||
result = result .. "|" .. entries[index] | result = result .. " || " .. entries[index] | ||
end | end | ||
end | end | ||
result = result .. "\n" | |||
end | end | ||
result = result .. "|}" | result = result .. "|}" | ||
return result | return result | ||
end | end | ||
| Line 115: | Line 115: | ||
function p.modes_table(frame) | function p.modes_table(frame) | ||
-- Mos is entered as a scale signature "xL ys" or "xL ys<p/q>" since the mos module can parse that format | -- Mos is entered as a scale signature "xL ys" or "xL ys<p/q>" since the mos module can parse that format | ||
local scale_sig = frame.args[ | local scale_sig = frame.args["Scale Signature"] or "5L 2s" | ||
local input_mos = mos.parse(scale_sig) | local input_mos = mos.parse(scale_sig) | ||
| Line 126: | Line 126: | ||
mode_names = tip.parse_entries(mode_names_unparsed) | mode_names = tip.parse_entries(mode_names_unparsed) | ||
else | else | ||
mode_names_unparsed = frame.args[ | mode_names_unparsed = frame.args["Mode Names"] | ||
mode_names = tip.parse_entries(mode_names_unparsed) | mode_names = tip.parse_entries(mode_names_unparsed) | ||
end | end | ||
| Line 133: | Line 133: | ||
-- For n headers, the number of entries must match the number of modes times the number of headers | -- For n headers, the number of entries must match the number of modes times the number of headers | ||
-- or else column data won't be added | -- or else column data won't be added | ||
local headers_unparsed = frame.args[ | local headers_unparsed = frame.args["Table Headers"] | ||
local headers = tip.parse_entries(headers_unparsed) | local headers = tip.parse_entries(headers_unparsed) | ||
local entries_unparsed = frame.args[ | local entries_unparsed = frame.args["Table Entries"] | ||
local entries = tip.parse_entries(entries_unparsed) | local entries = tip.parse_entries(entries_unparsed) | ||
return p._mos_modes(input_mos, mode_names, headers, entries) | |||
end | end | ||
return p | return p | ||