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

Module:MPvid

From WiKirby, your independent source of Kirby knowledge.
Revision as of 15:53, 6 March 2023 by Lakelimbo (talk | contribs) (ok i'd rather use the concats)
Jump to navigationJump to search

A version of MPvid that doesn't use #var. Pulls the videos from Module:MPvid/videos.

{{subst:#invoke:MPvid|random}}

--[[
	This module throws a random video from Module:MPvid/videos on every page refresh.
	If you can somehow spot server-side performance issues because of this
	module, please contact tech support.
]]--
local d = {}
local result = {}
local lang = mw.language.getContentLanguage()

function d.random ()
	-- The list of facts
	local z = require('Module:MPvid/videos')
	
	-- Generates a seed with the current server time.
	math.randomseed(os.time())

	-- The random selected video
	local choice = z[math.random(1,#z)]
	
	table.insert(result, '<div>{{Youtube|'.. choice.url ..'|350}}<div>'.. choice.caption ..'</div></div>')
	return table.concat(result, '')
end

return d