Module:Splash: Difference between revisions

From BTA-Mirror
imported>Ttv pedro270707
mNo edit summary
imported>Ttv pedro270707
m (Added special date splashes)
Line 4: Line 4:
function p.generateSplash()
function p.generateSplash()
math.randomseed(os.time())
math.randomseed(os.time())
local randomSplash = splashes.splashes[math.random(#splashes.splashes)]
local randomSplash = "missingno"
if 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 == 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 new year!"
else
randomSplash = splashes.splashes[math.random(#splashes.splashes)]
end
 
local div = mw.html.create('div')
local div = mw.html.create('div')
:addClass('splash-text')
:addClass('splash-text')

Revision as of 14:47, 12 March 2023

Documentation for this module may be created at Module:Splash/doc

local p = {}
local splashes = require("Module:Splash/splashes")

function p.generateSplash()
	math.randomseed(os.time())
	
	local randomSplash = "missingno"
	if 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 == 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 new year!"
	else
		randomSplash = splashes.splashes[math.random(#splashes.splashes)]
	end

	local div = mw.html.create('div')
	:addClass('splash-text')
    :attr('id', 'splash-text')
    :wikitext(randomSplash)
    :css('font-size', tostring(2880 / (#randomSplash*6 + 32)) .. 'px')
    
    return div
end

return p