Please remember that WiKirby contains spoilers, which you read at your own risk! See our general disclaimer for details.

Module:DYK: Difference between revisions

From WiKirby, your independent source of Kirby knowledge.
Jump to navigationJump to search
(Remake of {{DYK}})
 
m (Saving as this for now. (Not suitable for use yet))
Line 7: Line 7:
local p1 = math.random( lang:formatDate("n") , #z )
local p1 = math.random( lang:formatDate("n") , #z )
local p2 = math.random( lang:formatDate("W") , #z )
local p2 = math.random( lang:formatDate("j") , #z )
local p3 = math.random( lang:formatDate("z") , #z )
local p3 = math.random( math.floor(#z / lang:formatDate("z")) , #z )
local y1 = z[p1]
local y1 = z[p1]

Revision as of 20:27, 7 June 2022

A version of {{DYK}} that doesn't use #var. Pulls the facts from Module:DYK/facts. Use by typing {{#invoke:DYK|random}}.


local d = {}
local lang = mw.language.getContentLanguage()
local result = {}

function d.random ()
	local z = require('Module:DYK/facts')
	
	local p1 = math.random( lang:formatDate("n") , #z )
	local p2 = math.random( lang:formatDate("j") , #z )
	local p3 = math.random( math.floor(#z / lang:formatDate("z")) , #z )
	
	local y1 = z[p1]
	local y2 = z[p2]
	local y3 = z[p3]
	
	table.insert(result, '<ul><li>'.. y1 ..'</li><li>'.. y2 ..'</li><li>'.. y3 ..'</li></ul>')
	return table.concat(result, '')
end

return d