Module:Sandbox/維基搗蛋鬼/rand
跳到导航
跳到搜索
local func = {} function func.randitem( frame ) local text = frame.args[1] local list = mw.text.split(text, frame.args[2] or '[\n\r]%s*%*%s*') math.randomseed(os.time()) local n = #list local r = 0 if mw.text.trim(list[1]) == '' then r = math.random(n - 1) + 1 else r = math.random(n) end return mw.text.trim(list[r]) end return func