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 01:58, 31 July 2015 (Created page with 'local p = {} -- Named argument |list= used, like: {{#invoke:Sandbox/Evad37/Random TAFI|choose|list=*item1 *item2 *item3}} function p.choose(frame)...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

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