Module:Splash
Documentation for this module may be created at Module:Splash/doc
local p = {} local splashes = require("Module:Splash/splashes") local charWidths = { ['!'] = 2, ['.'] = 2, [','] = 2, [':'] = 2, ['\''] = 2, ['i'] = 2, -- width 1 characters ['l'] = 3, -- width 2 characters ['I'] = 4, ['t'] = 4, [' '] = 4, -- width 3 characters ['k'] = 5, ['<'] = 5, ['>'] = 5, ['f'] = 5, -- width 4 characters ['A'] = 6, ['B'] = 6, ['C'] = 6, ['D'] = 6, ['E'] = 6, ['F'] = 6, ['G'] = 6, ['H'] = 6, ['J'] = 6, ['K'] = 6, ['L'] = 6, ['M'] = 6, ['N'] = 6, ['O'] = 6, ['P'] = 6, ['Q'] = 6, ['R'] = 6, ['S'] = 6, ['T'] = 6, ['U'] = 6, ['V'] = 6, ['W'] = 6, ['X'] = 6, ['Y'] = 6, ['Z'] = 6, ['a'] = 6, ['b'] = 6, ['c'] = 6, ['d'] = 6, ['e'] = 6, ['g'] = 6, ['h'] = 6, ['j'] = 6, ['m'] = 6, ['n'] = 6, ['o'] = 6, ['p'] = 6, ['q'] = 6, ['r'] = 6, ['s'] = 6, ['u'] = 6, ['v'] = 6, ['w'] = 6, ['x'] = 6, ['y'] = 6, ['z'] = 6, ['0'] = 6, ['1'] = 6, ['2'] = 6, ['3'] = 6, ['4'] = 6, ['5'] = 6, ['6'] = 6, ['7'] = 6, ['8'] = 6, ['9'] = 6, ['='] = 6, ['-'] = 6, ['^'] = 6 } function p.generateSplash( f ) local args = f if f == mw.getCurrentFrame() then args = require( 'Module:ProcessArgs' ).merge( true ) else f = mw.getCurrentFrame() end math.randomseed(os.time()) local randomSplash = "missingno" if args.splash then randomSplash = args.splash elseif os.date("*t", os.time()).month == 1 and os.date("*t", os.time()).day == 19 then randomSplash = "Happy birthday, jonkadelic!" elseif os.date("*t", os.time()).month == 4 and os.date("*t", os.time()).day == 29 then randomSplash = "Happy birthday, MaggAndGeez!" elseif os.date("*t", os.time()).month == 5 and os.date("*t", os.time()).day == 17 then randomSplash = "Happy birthday, Minecraft!" elseif os.date("*t", os.time()).month == 7 and os.date("*t", os.time()).day == 20 then randomSplash = "Happy birthday, Better than Adventure!" elseif os.date("*t", os.time()).month == 12 and os.date("*t", os.time()).day == 24 then randomSplash = "Merry X-mas!" elseif os.date("*t", os.time()).month == 1 and os.date("*t", os.time()).day == 1 then randomSplash = "Happy Halloween!" elseif os.date("*t", os.time()).month == 10 and os.date("*t", os.time()).day == 31 then randomSplash = "Happy New Year!" else randomSplash = splashes.splashes[math.random(#splashes.splashes)] end local splashWidth = 0 for i = 1, #randomSplash do local char = randomSplash:sub(i, i) -- Look up the pixel width of the character in the table local charWidth = charWidths[char] if not charWidth then charWidth = 6 -- Default width end -- Add the pixel width of the character to the total width splashWidth = splashWidth + charWidth end local div = mw.html.create('div') :addClass('splash-text') :attr('id', 'splash-text') :wikitext(randomSplash) :css('font-size', tostring(2880 / (splashWidth + 32)) .. 'px') return div end return p