Module:Infobox AFDO: Difference between revisions

ArrowHead294 (talk | contribs)
mNo edit summary
m Bugfix
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
local p = {}
local p = {}
local getArgs = require("Module:Arguments").getArgs
local infobox = require("Module:Infobox")
local u = require("Module:Utils")
local u = require("Module:Utils")
local infobox = require("Module:Infobox")
local yesno = require("Module:Yesno")


function p.infobox_AFDO(frame)
function p.infobox_AFDO(frame)
local args = getArgs(frame)
-- debug mode will disable the categories
-- debug mode will disable the categories
local debug_mode = frame.args["debug"] ~= nil
local debug_mode = yesno(frame.args["debug"] or args["debug"], false)
local wtext = yesno(frame.args["wtext"] or args["wtext"])
local categories = ""
local categories = ""
Line 31: Line 36:
})
})


table.insert(infobox_data, {
     if (dualfifth) then
"Fifth",
fifth .. "/" .. steps .. " (" .. math.floor(math.log(fifth / steps) / math.log(2) * 1200 * 1000) / 1000 .. "c)"
})
 
     if(dualfifth) then
     table.insert(infobox_data, {
     table.insert(infobox_data, {
"Dual sharp fifth",
"Dual sharp fifth",
Line 45: Line 45:
(fifth-1) .. "/" .. steps .. " (" .. math.floor(math.log((fifth - 1) / steps) / math.log(2) * 1200 * 1000) / 1000 .. "c)"
(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
     end


  if(special_properties ~= "") then
    if (special_properties ~= "") then
   table.insert(infobox_data, {"Special properties", special_properties})
   table.insert(infobox_data, {"Special properties", special_properties})
   end
   end


local result = infobox.build(
local result = infobox.build(
"[[" .. steps .. "afdo]]",
string.format("[[%safdo]]", steps),
infobox_data,
infobox_data,
"[[" .. (steps - 1) .. "afdo|← " .. (steps - 1) .. "afdo]]",
string.format("[[%safdo|← %safdo]]", steps - 1, steps - 1),
"[[" .. (steps + 1) .. "afdo|" .. (steps + 1) .. "afdo →]]"
string.format("[[%safdo|%safdo →]]", steps + 1, steps + 1)
)
)
Line 61: Line 67:
result = result .. categories
result = result .. categories
end
end
return result
if wtext then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return frame:preprocess(result)
end
end


return p
return p