Module:Sandbox/BrownHairedGirl/xyz explained

local p =

function make_cat_link(catname, disp) local displaytext if (disp ~= "") then displaytext = disp else displaytext = catname end local link = "" .. displaytext .. "" local fmtlink local linktitle = mw.title.new(catname, "Category") if (linktitle.exists) then fmtlink = link else fmtlink = "

" .. displaytext .. "" end

return fmtlinkend

function make_cat_link4(catname, disp) local link = "" return linkend

function make_decade_cat_link(prefix, start, rest, decadenum) local decadestart = (prefix * 100) + (decadenum * 10) local decadename = decadestart .. "s" return make_cat_link(start .. decadename .. rest, decadename)end

function ordinal_numbers(n) local ordinal, digit =, string.sub(n, -1) if tonumber(digit) > 0 and tonumber(digit) <= 3 and mw.ustring.sub(n,-2) ~= 11 and mw.ustring.sub(n,-2) ~= 12 and mw.ustring.sub(n,-2) ~= 13 then return n .. ordinal[tonumber(digit)] else return n .. "th" endend

function make_century_name(n) local centuryordinal = ordinal_numbers(n) return centuryordinal .. " century"end

function p.main(frame) local pagename local nilly if (frame.args[1] ~= "") then -- a parameter was supplied, so use it as page title nilly = "no nil. value='" .. frame.args[1] .. "'" if (string.match(frame.args[1], "^Category *: *")) then pagename = mw.ustring.gsub(frame.args[1], "^Category *: *", ""); else pagename = frame.args[1] end else -- use the page title nilly = "nil" pagename = mw.title.getCurrentTitle.text end if (false) then return nilly end local dddo = mw.ustring.match(pagename, "%d%d*0s") if (dddo

nil) then return "Error: no 'YYOs' in '" .. pagename .. "'" end local dd = mw.ustring.match(dddo, "^%d*") local yy = (dd - (dd % 100))/ 100 local startoftitle = mw.ustring.gsub(pagename, dddo .. ".*$", "") local restoftitle = mw.ustring.gsub(pagename, "^.*" .. dddo, "") local diagnotics = "; pagename\n* " .. pagename .. "\n;dddo\n*" .. dddo .. "\n;dd\n*" .. dd diagnotics = diagnotics .. "\n;yy\n*" .. yy .. "\n;startoftitle\n*'" .. startoftitle .. "'" diagnotics = diagnotics .. "\n;restoftitle\n*'" .. restoftitle .. "'" local retval retval = "

-\nstyle=\"text-align:center\"" .. startoftitle if (startoftitle

"") then retval = retval .. "Decades " else retval = retval .. " decades " end retval = retval .. " of the " .. make_century_name(yy+1) .. restoftitle .. "\n

-\n" retval = retval .. "" .. make_decade_cat_link(yy, startoftitle, restoftitle, -1) .. " • " .. "" local i; for i = 0, 9 do retval = retval .. make_decade_cat_link(yy, startoftitle, restoftitle, i) if i < 9 then retval = retval .. " • " end end retval = retval .. "" .. " • " .. make_decade_cat_link(yy, startoftitle, restoftitle, 10) .. "" retval = retval .. "\n
" return retvalend

return p