Module:Infobox MOS: Difference between revisions
Fixed wrong args being passed |
Moved categories to helper function |
||
| Line 43: | Line 43: | ||
local mult = 10^(numDecimalPlaces or 0) | local mult = 10^(numDecimalPlaces or 0) | ||
return math.floor(num * mult + 0.5) / mult | return math.floor(num * mult + 0.5) / mult | ||
end | |||
-- Helper function | |||
-- Adds categories | |||
function p.categorize(tuning) | |||
local tuning = tuning or "5L 2s" | |||
local input_mos = MOS.parse(tuning) | |||
-- Add to category of abstact mosses | |||
local categories = "[[Category:Abstract MOS patterns]]" | |||
-- Add tuning category | |||
categories = categories .. "\n" .. string.format('[[Category:%s]]', tuning) | |||
-- Add notecount category if the notecount is greater than 3 | |||
local notecount = input_mos.nL + input_mos.ns | |||
if notecount > 3 then | |||
categories = categories .. "\n" .. string.format('[[Category:%d-tone scales]]', notecount) | |||
end | |||
-- Add to nonoctave category if the equave is nonoctave | |||
if not rat.eq(input_mos.equave, rat.new(2)) then | |||
categories = categories .. "\n" .. '[[Category:Nonoctave]]' | |||
end | |||
return categories | |||
end | end | ||
| Line 52: | Line 78: | ||
local other_names = other_names or nil | local other_names = other_names or nil | ||
local mos = MOS.parse(tuning) | local mos = MOS.parse(tuning) | ||
local equave = mos.equave | local equave = mos.equave | ||
| Line 266: | Line 280: | ||
) | ) | ||
if not debug_mode then | if not debug_mode then | ||
result = result .. "\n" .. | result = result .. "\n\n" .. p.categorize(tuning) | ||
end | end | ||
return result | return result | ||