Module:Scale tree: Difference between revisions

Ganaram inukshuk (talk | contribs)
m Table header text
Ganaram inukshuk (talk | contribs)
Separated step ratio and hardness back into separate columns
Line 90: Line 90:
result = result .. '! rowspan="2" | Generator (in steps)\n'
result = result .. '! rowspan="2" | Generator (in steps)\n'
result = result .. '! colspan="2" | Generator (in cents)\n'
result = result .. '! colspan="2" | Generator (in cents)\n'
result = result .. '! rowspan="2" | Step ratio (hardness)\n'
result = result .. '! colspan="2" | Step ratio\n'
result = result .. '! rowspan="2" | Comments\n'
result = result .. '! rowspan="2" | Comments\n'
result = result .. '|-\n'
result = result .. '|-\n'
result = result .. '! Bright\n'
result = result .. '! Bright\n'
result = result .. '! Dark\n'
result = result .. '! Dark\n'
result = result .. '! L:s\n'
result = result .. '! Hardness\n'


-- Rounding is done using string.format, to 3 decimal places (%.3f)
-- Rounding is done using string.format, to 3 decimal places (%.3f)
Line 123: Line 125:
result = result .. string.format("| %.3f\n", dark_generator_cents)
result = result .. string.format("| %.3f\n", dark_generator_cents)
-- Cell for step ratio, with divide-by-zero check
-- Cell for step ratio
local hardness = -1
result = result .. string.format("| %d:%d\n", step_ratio[1], step_ratio[2])
-- Cell for hardness, with divide-by-zero check
local hardness = ""
if step_ratio[2] == 0 then
if step_ratio[2] == 0 then
hardness = "→ ∞"
hardness = "→ ∞"
Line 130: Line 135:
hardness = string.format("%.3f", step_ratio[1] / step_ratio[2])
hardness = string.format("%.3f", step_ratio[1] / step_ratio[2])
end
end
local step_ratio_as_string = string.format("%d:%d", step_ratio[1], step_ratio[2])
result = result .. string.format("| %s\n", hardness)
result = result .. string.format("| %s (%s)\n", step_ratio_as_string, hardness)
-- Cell for comment
-- Cell for comment