Documentation for this module may be created at Module:RandomText/doc
1 inspect = require("Module:InspectLua")
2 local p = {}
3
4 function p.pp(text)
5 return mw.getCurrentFrame():preprocess(text)
6 end
7
8 function p.randomizeText (frame)
9 local args = frame:getParent().args
10 local textArray = {}
11 local allText = args[1]
12 for word in string.gmatch(allText, '[^\r\n]+') do
13 table.insert(textArray, word)
14 end
15
16 math.randomseed(os.time())
17 local randomIndex = math.random(table.getn(textArray))
18 return p.pp(textArray[randomIndex])
19 end
20
21 return p
