Jump to content

Module:Choose random TAFI

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Evad37 (talk | contribs) at 02:08, 31 July 2015 (split based on # (from numbered list)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

-- Named argument |list= used, like: {{#invoke:Sandbox/Evad37/Random TAFI|choose|list=#[[item1]] #[[item2]] #[[item3]]}}

function p.choose(frame)
	local list = frame.args.list                     -- List of articles inputed via a single paramtere
	local articles = mw.text.split(list, '#')       -- Split list into an array of substrings (each containing an article)
	local doRandom = require('Module:Random').main   -- Import module function to work with substrings
	articles.limit = '1'                             -- Configuration for module function
	local chosen = doRandom("list", articles)
	return chosen
end

return p