Module:RandomText
跳到导航
跳到搜索
local module = {} function module.RandomList(frame) local parent = frame:getParent() if parent and parent:getTitle() == "Template:RandomText" then frame = parent end if not frame.args["Data"] then return -1 end local data = mw.loadData("Module:RandomText/"..frame.args["Data"]) local count = data.count data = data.data local result = {} local ttime = os.date("!*t", os.time()) local seed = tonumber(tostring(ttime.year)..tostring(ttime.yday)) math.randomseed(seed) for j=1,count do local length = data[j].length or 1 for i=1,length do table.insert(result, data[j].list[math.random(data[j].count)]) end end return frame:preprocess(table.concat(result, "、")) end return module