Module:Dynamic infobox

--

-- Module to build an infobox with data from a Lua database.

local p = {} local getArgs = require("Dev:Arguments").getArgs local userError = require("Dev:User error") local data = mw.loadData("Module:Dynamic infobox/data")

function p.main(frame) local args = getArgs(frame) local infobox = mw.html.create("infobox") :attr("type", "multi-column")

for _, alias in ipairs(args) do       local skill = data[alias]

if not skill then return userError("'" .. alias .. "' is not a skill in the MARDEK series") end

infobox:tag("group") :attr("row-items", "3") :attr("collapse", "closed") :tag("header") :wikitext("" .. skill.name .. "") :done :tag("data") :attr("span", 3) :tag("label") :wikitext("Formula") :done :tag("default") :tag("math") :wikitext("y = mx + b") :done :done :done :tag("data") :tag("label") :wikitext("Element") :done :tag("default") :wikitext(skill.element) :done :done :tag("data") :tag("label") :wikitext("Type") :done :tag("default") :wikitext(skill.type) :done :done :tag("data") :tag("label") :wikitext("Cost") :done :tag("default") :wikitext(skill.cost .. " MP") :done :done :tag("data") :tag("label") :wikitext("Power") :done :tag("default") :wikitext(skill.power) :done :done :tag("data") :tag("label") :wikitext("Accuracy") :done :tag("default") :wikitext(skill.accuracy .. "%") :done :done :tag("data") :tag("label") :wikitext("Critical") :done :tag("default") :wikitext(skill.critical .. "%") :done :done :tag("data") :tag("label") :wikitext("Target") :done :tag("default") :wikitext(skill.target) :done :done end

return frame:preprocess(tostring(infobox)) end

return p --