Module:VOCALOID殿堂曲/Random Song
跳到导航
跳到搜索
local module = {} local getArgs = require('Module:Arguments').getArgs function getRandomNumber(mtr6) local max = tonumber(mtr6) local ran = math.random(1, max) + tonumber(os.time()) return ran % max end function random_count(count, mtr6, content_table) local result = {} repeat local ran = getRandomNumber(mtr6) result[#result + 1] = content_table[ran] until (#result >= count) return table.concat(result, "\n") end function module.temple(args, frame) local titleName = args['page'] or '' local title = mw.title.new(titleName) local content_before = title:getContent() local mtr1, mtr2 = string.gsub(content_before, "Temple ?_?Song", "") local content_table = {} local pattern = "{{Temple ?_?Song.-|image.-}}\n" local mtr4 = content_before for i = 1, mtr2, 1 do local mtr3 = string.match(mtr4, pattern) mtr4 = string.gsub(mtr4, pattern, "", 1) content_table[i] = mtr3 end local count = tonumber(args['count']) or 6 local mtr5 = random_count(count, mtr2, content_table) --local content = frame:preprocess(content_before) return frame:preprocess(mtr5) end function module.templemain(frame) local args = getArgs(frame) return module.temple(args, frame) end return module