Module:MOS modes: Difference between revisions

Ganaram inukshuk (talk | contribs)
No edit summary
Ganaram inukshuk (talk | contribs)
Preparing to make the modes table into a template
Line 49: Line 49:
-- Test function that produces the modes of a mos as a table
-- Test function that produces the modes of a mos as a table
-- TODO:
-- TODO:
-- - Allow for mos to be extracted from the page's title for use as a future template
-- - Allow for input of mode names
-- - Allow for input of mode names
-- - Expand this (possibly as a separate template) for mos intervals
-- - Expand this (possibly as a separate template) for mos intervals
function p.modes_table(frame)
function p.modes_table(frame)
-- Mos is entered as "xL ys" since the mos module can parse that format
-- Mos is entered as "xL ys" or "xL ys<p/q>" since the mos module can parse that format
local mosstring = "3L 4s"
local mosstring = frame.args['Tuning'] or "5L 2s"
local input_mos = mos.parse(mosstring)
local input_mos = mos.parse(mosstring)
Line 64: Line 63:
result = result .. "|+ " .. "Modes of " .. mosstring .. "\n"
result = result .. "|+ " .. "Modes of " .. mosstring .. "\n"
result = result .. "|-\n"
result = result .. "|-\n"
result = result .. "! Mode\n"
result = result .. "! [[UDP]]\n"
result = result .. "! [[UDP]]\n"
result = result .. "! Step pattern\n"
-- Enter each row
-- Enter each row
-- As of coding, mos mode listings are fairly inconsistent or nonexistent, but consist of
-- the UDP, step pattern, and any mode names(s) in some order
-- This table orders them as UDP, step pattern, and (TODO) mode names, as that's more common
for i = 1, #mos_modes do
for i = 1, #mos_modes do
result = result .. "|-\n"
result = result .. "|-\n"
-- Add the mode's string
result = result .. "|" .. mos_modes[i] .. "\n"
-- Add the UDP, formatted as up|dp, where u is the number of bright generators going up,
-- Add the UDP, formatted as up|dp, where u is the number of bright generators going up,
-- d is the number of bright generators going down, and p is the number of periods
-- d is the number of bright generators going down, and p is the number of periods
-- (slightly different from standard UDP notation of u|d(p))
-- (slightly different from standard UDP notation of up|dp(p))
local gens_down = (i - 1) * periods
local gens_down = (i - 1) * periods
local gens_up = (#mos_modes - i) * periods
local gens_up = (#mos_modes - i) * periods
result = result .. "|" .. gens_up .. '&#124;' .. gens_down .. "\n"
result = result .. "|" .. gens_up .. '&#124;' .. gens_down .. "\n"
-- Add the mode's step pattern
result = result .. "|" .. mos_modes[i] .. "\n"
end
end