Module:MaroScale
Documentation for this module may be created at Module:MaroScale/doc
-- Little bit of Lua for building tables for the Storm and Rabiah scales. -- Mechanics have be re-ranked in the past, and it's probably interesting to track their drift. -- Rather than force editors to track the newest one, let's see if we can't do it in code. local MaroScale = {} function MaroScale.RowBuilder(frame) local args = frame:getParent().args -- coming from one layer up if args then local s = "" for k,v in pairs(args) do s = s.."k: "..v..", " end return s end local name = frame.args.name local highest = 0 -- local highestDate = "" local ratings = {} string.gsub(frame.args.ratings, "{([^\}]+)}", function(a) local rating, refDate, refString = string.gsub(a, "(%d+),([%d%-]+),(.+)") table.insert(ratings, {rating = rating, refDate = refDate, refString = refString}) if rating > highest then highest = rating -- highestDate = refDate end end) -- maybe later, it's not worth the effort right now -- table.sort(ratings, function(a,b) return a.refDate < b.refDate end) local row = mw.html.create("tr") :tag("td"):wikitext(name):done() :tag("td"):wikitext(highest):done() :tag("td"):tag("ul") for _, rating in pairs(ratings) do row:tag("li"):wikitext(rating.refString):done() end row:allDone() return row end return MaroScale