Module:Infobox AFDO: Difference between revisions
Jump to navigation
Jump to search
Trying to make it so that “fifth” doesn’t show up when “sharp dual fifth” and “flat dual fifth” show up, because then it is being shown twice which is redundant. I will check the afdo pages immediately to see if it has broken them, and will undo immediately if it has Tags: Mobile edit Mobile web edit Advanced mobile edit |
ArrowHead294 (talk | contribs) mNo edit summary |
||
| Line 2: | Line 2: | ||
local u = require("Module:Utils") | local u = require("Module:Utils") | ||
local infobox = require("Module:Infobox") | local infobox = require("Module:Infobox") | ||
local yesno = require("Module:Yesno") | |||
function p.infobox_AFDO(frame) | function p.infobox_AFDO(frame) | ||
-- debug mode will disable the categories | -- debug mode will disable the categories | ||
local debug_mode = frame.args["debug"] | local debug_mode = yesno(frame.args["debug"]) | ||
local categories = "" | local categories = "" | ||
| Line 48: | Line 49: | ||
end | end | ||
if (special_properties ~= "") then | |||
table.insert(infobox_data, {"Special properties", special_properties}) | table.insert(infobox_data, {"Special properties", special_properties}) | ||
end | end | ||
| Line 59: | Line 60: | ||
) | ) | ||
return frame:preprocess(debug_mode == true and "<pre>" .. result .. "</pre>" or result .. categories) | |||
end | end | ||
return p | return p | ||
Revision as of 14:05, 27 February 2025
- This module should not be invoked directly; use its corresponding template instead: Template:Infobox AFDO.
Generates an infobox providing information about a given arithmetic frequency division of the octave.
| Introspection summary for Module:Infobox AFDO | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| ||||||||||||||||||
No function descriptions were provided. The Lua code may have further information.
local p = {}
local u = require("Module:Utils")
local infobox = require("Module:Infobox")
local yesno = require("Module:Yesno")
function p.infobox_AFDO(frame)
-- debug mode will disable the categories
local debug_mode = yesno(frame.args["debug"])
local categories = ""
local steps = frame.args["steps"]
local stepnum = tonumber(steps)
local dualfifth = stepnum % 2 == 1
local fifth = steps+math.ceil(steps/2)
local special_properties = ""
categories = categories .. "[[Category:AFDO|" .. string.rep("#", string.len (stepnum)) .. "]]"
-- prime test
local prime = ""
if u.is_prime(stepnum) then
prime = " (prime)"
-- if rat.eq(et.equave, 2) then
categories = categories .. "[[Category:Prime AFDO|" .. string.rep("#", string.len (stepnum)) .. "]]"
-- end
end
local infobox_data = {}
table.insert(infobox_data, {
"Prime factorization",
u._prime_factorization(stepnum) .. prime
})
if(dualfifth) then
table.insert(infobox_data, {
"Dual sharp fifth",
fifth .. "/" .. steps .. " (" .. math.floor(math.log(fifth / steps) / math.log(2) * 1200 * 1000) / 1000 .. "c)"
})
table.insert(infobox_data, {
"Dual flat fifth",
(fifth-1) .. "/" .. steps .. " (" .. math.floor(math.log((fifth - 1) / steps) / math.log(2) * 1200 * 1000) / 1000 .. "c)"
})
else
table.insert(infobox_data, {
"Fifth",
fifth .. "/" .. steps .. " (" .. math.floor(math.log(fifth / steps) / math.log(2) * 1200 * 1000) / 1000 .. "c)"
})
end
if (special_properties ~= "") then
table.insert(infobox_data, {"Special properties", special_properties})
end
local result = infobox.build(
"[[" .. steps .. "afdo]]",
infobox_data,
"[[" .. (steps - 1) .. "afdo|← " .. (steps - 1) .. "afdo]]",
"[[" .. (steps + 1) .. "afdo|" .. (steps + 1) .. "afdo →]]"
)
return frame:preprocess(debug_mode == true and "<pre>" .. result .. "</pre>" or result .. categories)
end
return p