Module:Numlinks 2-num: Difference between revisions

Ganaram inukshuk (talk | contribs)
No edit summary
Ganaram inukshuk (talk | contribs)
add link count, for testing
Line 17: Line 17:
--  if the page were 1L 1s, there would be no link to 0L 0s.
--  if the page were 1L 1s, there would be no link to 0L 0s.
-- - No option exists for the number of links in each direction.
-- - No option exists for the number of links in each direction.
local curr_num_1 = args["Current Num 1"]
local curr_num_1 = args["Current Num 1"]
local curr_num_2 = args["Current Num 2"]
local curr_num_2 = args["Current Num 2"]
local min_num_1 = args["Min 1"] or 1
local num_links_1 = args["Link Count 1"] or 1
local min_num_2 = args["Min 2"] or 1
local num_links_2 = args["Link Count 2"] or 1
local min_num_1   = args["Min 1"] or 1
local min_num_2   = args["Min 2"] or 1
-- Format strings.
-- Format strings.
Line 62: Line 64:
end
end
-- Create a grid of links
local num_rows = 1 + num_links_2 * 2
local num_cols = 1 + num_links_1 * 2
local links = {}
local links = {}
for j = 1, num_rows do
local num_links_1 = 1
local num_links_2 = 1
for j = 1, 1 + num_links_2 * 2 do
local row = {}
local row = {}
for i = 1, 1 + num_links_1 * 2 do
for i = 1, num_cols do
local num_2 = format_number(curr_num_2 + i - 2, is_ordinal_2)
local num_2 = format_number(curr_num_2 + i - 2, is_ordinal_2)
local num_1 = format_number(curr_num_1 + j - 2, is_ordinal_1)
local num_1 = format_number(curr_num_1 + j - 2, is_ordinal_1)
Line 86: Line 88:
table.insert(lines, '{| style="width: 100%;"')
table.insert(lines, '{| style="width: 100%;"')
local middle_cell_width = 100 / (num_links_1 + 2)
local middle_cell_width = 100 / (num_links_1 + 2)
for j = 1, 1 + num_links_2 * 2 do
for j = 1, num_rows do
-- New row
-- New row
table.insert(lines, '|-')
table.insert(lines, '|-')
for i = 1, 1 + num_links_1 * 2 do
for i = 1, num_cols do
if i == num_links_1 + 1 then
if i == num_links_1 + 1 then
if j == num_links_2 + 1 then
if j == num_links_2 + 1 then
Line 118: Line 120:
args["Min 1"] = tonumber(args["Min 1"]) or 1
args["Min 1"] = tonumber(args["Min 1"]) or 1
args["Min 2"] = tonumber(args["Min 2"]) or 1
args["Min 2"] = tonumber(args["Min 2"]) or 1
args["Link Count 1"] = tonumber(args["Link Count 1"]) or 1
args["Link Count 2"] = tonumber(args["Link Count 2"]) or 1
-- Preprocess toggles
-- Preprocess toggles