Module:JI ratio finder: Difference between revisions

Ganaram inukshuk (talk | contribs)
Removed functions pertaining to complement-agnostic tenney height; superseded by nefth functions
Ganaram inukshuk (talk | contribs)
No edit summary
Line 311: Line 311:
-- Converts ratios to text, with delimiter
-- Converts ratios to text, with delimiter
-- Default delimiter is a comma followed by a space
-- Default delimiter is a comma followed by a space
function p.ratios_to_text(ratios, delimiter)
function p.ratios_to_text(ratios, delimiter, add_links)
local ratios = ratios or { rat.new(5, 4), rat.new(81, 64), rat.new(9, 7) }
local ratios = ratios or { rat.new(5, 4), rat.new(81, 64), rat.new(9, 7) }
local delimiter = delimiter or ", "
local delimiter = delimiter or ", "
local add_links = add_links == true


local text = ""
local text = ""
for i = 1, #ratios do
if add_links then
text = text .. rat.as_ratio(ratios[i])
for i = 1, #ratios do
if i < #ratios then
text = text .. string.format("[[%s]]", rat.as_ratio(ratios[i]))
text = text .. delimiter
if i < #ratios then
text = text .. delimiter
end
end
else
for i = 1, #ratios do
text = text .. rat.as_ratio(ratios[i])
if i < #ratios then
text = text .. delimiter
end
end
end
end
end