Module:Infobox AFDO: Difference between revisions
m Fix |
ArrowHead294 (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local u = require( | local u = require("Module:Utils") | ||
local infobox = require( | local infobox = require("Module:Infobox") | ||
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[ | local debug_mode = frame.args["debug"] ~= nil | ||
local categories = | local categories = "" | ||
local steps = frame.args[ | local steps = frame.args["steps"] | ||
local stepnum = tonumber(steps) | local stepnum = tonumber(steps) | ||
local dualfifth = stepnum % 2 == 1 | local dualfifth = stepnum % 2 == 1 | ||
| Line 14: | Line 14: | ||
local special_properties = "" | local special_properties = "" | ||
categories = categories .. "[[Category:AFDO|" .. string.rep("#", string.len (stepnum)) .. "]]" | |||
-- prime test | -- prime test | ||
| Line 28: | Line 21: | ||
prime = " (prime)" | prime = " (prime)" | ||
-- if rat.eq(et.equave, 2) then | -- if rat.eq(et.equave, 2) then | ||
categories = categories .. | categories = categories .. "[[Category:Prime AFDO|" .. string.rep("#", string.len (stepnum)) .. "]]" | ||
-- end | -- end | ||
end | end | ||
| Line 34: | Line 27: | ||
local infobox_data = {} | local infobox_data = {} | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
"Prime factorization", | |||
u._prime_factorization(stepnum) .. prime | u._prime_factorization(stepnum) .. prime | ||
}) | }) | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
"Fifth", | |||
fifth .. | fifth .. "/" .. steps .. " (" .. math.floor(math.log(fifth / steps) / math.log(2) * 1200 * 1000) / 1000 .. "c)" | ||
}) | }) | ||
if(dualfifth) then | if(dualfifth) then | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
"Dual sharp fifth", | |||
fifth .. | fifth .. "/" .. steps .. " (" .. math.floor(math.log(fifth / steps) / math.log(2) * 1200 * 1000) / 1000 .. "c)" | ||
}) | }) | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
"Dual flat fifth", | |||
(fifth-1) .. | (fifth-1) .. "/" .. steps .. " (" .. math.floor(math.log((fifth - 1) / steps) / math.log(2) * 1200 * 1000) / 1000 .. "c)" | ||
}) | }) | ||
end | end | ||
if(special_properties ~= "") then | if(special_properties ~= "") then | ||
table.insert(infobox_data, { | table.insert(infobox_data, {"Special properties", special_properties}) | ||
end | end | ||
local result = infobox.build( | local result = infobox.build( | ||
"←<span style=\"font-size: 0.75em;\"> [[" .. (steps - 1).. "afdo]] </span>" | |||
.. "[[" .. steps .. "afdo]]" | |||
.. "<span style=\"font-size: 0.75em;\"> [[" .. (steps + 1).. "afdo]] →</span>", | |||
infobox_data | infobox_data | ||
) | ) | ||