Module:SB tree: Difference between revisions
No edit summary |
Added option to stagger ratios (work-in-progress) |
||
| Line 118: | Line 118: | ||
-- To try this out, add the following text (not as a lua comment): | -- To try this out, add the following text (not as a lua comment): | ||
-- {{#invoke:SB_tree|sb_table}} | -- {{#invoke:SB_tree|sb_table}} | ||
function p.sb_table(frame) | function p.sb_table(frame) | ||
-- Call the sb function | -- Call the sb function | ||
| Line 126: | Line 125: | ||
local start_ratio_unparsed = frame.args['Start Ratio'] or "1/1" | local start_ratio_unparsed = frame.args['Start Ratio'] or "1/1" | ||
local stop_ratio_unparsed = frame.args['Stop Ratio'] or "1/0" | local stop_ratio_unparsed = frame.args['Stop Ratio'] or "1/0" | ||
local stagger_ratios = frame.args['Stagger Ratios'] or true | |||
-- Parse ratios | -- Parse ratios | ||
| Line 140: | Line 140: | ||
result = result .. "|-\n" | result = result .. "|-\n" | ||
-- Create the | -- Create the header cell | ||
result = result .. '! colspan="' .. depth + edge_extend + 1 .. " | Ratios\n" | if stagger_ratios then | ||
result = result .. '! colspan="' .. depth + edge_extend + 1 .. " | Ratios\n" | |||
else | |||
result = result .. "| Ratios\n" | |||
end | |||
-- Create the individual rows | -- Create the individual rows | ||
| Line 148: | Line 152: | ||
result = result .. "|-\n" | result = result .. "|-\n" | ||
-- Create the cells for each row | -- Create the cells for each row | ||
-- | if stagger_ratios then | ||
-- Stagger ratios | |||
for j = 1, depth + edge_extend + 1 do | |||
if j == sb_tree_depths[i] then | |||
result = result .. "|" .. sb_tree_ratios[i][1] .. "/" .. sb_tree_ratios[i][2] .. "\n" | |||
else | |||
result = result .. "|\n" | |||
end | |||
end | end | ||
else | |||
-- Don't stagger ratios | |||
result = result .. "|" .. sb_tree_ratios[i][1] .. "/" .. sb_tree_ratios[i][2] .. "\n" | |||
end | end | ||
end | end | ||