Module:MOS modes: Difference between revisions
mNo edit summary |
No edit summary |
||
| Line 81: | Line 81: | ||
-- This is for entering multiple columns of info, if a single column of mode names isn't enough | -- This is for entering multiple columns of info, if a single column of mode names isn't enough | ||
-- For n | -- 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 | local headers_unparsed = frame.args['Headers'] | ||
local | local headers = p.parse_entries(headers_unparsed) | ||
local | local entries_unparsed = frame.args['Entries'] | ||
local | local entries = p.parse_entries(entries_unparsed) | ||
-- To determine whether to add additional columns, determine whether the number of entries | -- To determine whether to add additional columns, determine whether the number of entries | ||
-- and the number of columns are | -- and the number of columns are greater than zero, and if so, determine whether the number of entries | ||
-- | -- is equal to the number of headers times the number of modes | ||
local add_columns = number_of_columns | local add_columns = number_of_columns > 0 and number_of_entries > 0 | ||
if add_columns then | if add_columns then | ||
add_columns = add_columns and # | add_columns = add_columns and #modes * #headers == #entries | ||
end | end | ||
| Line 112: | Line 112: | ||
-- If mode names and columns are used, mode names come first | -- If mode names and columns are used, mode names come first | ||
if add_columns then | if add_columns then | ||
for i = 1, # | for i = 1, #headers do | ||
result = result .. "! " .. | result = result .. "! " .. headers[i] .. "\n" | ||
end | end | ||
end | end | ||
| Line 141: | Line 141: | ||
-- Add columns if given | -- Add columns if given | ||
if add_columns then | if add_columns then | ||
for j = 1, # | for j = 1, #headers do | ||
result = result .. "|" .. | result = result .. "|" .. entries[i + j - 1] .. "\n" | ||
end | end | ||
end | end | ||