跳转到内容

模組:Rand

维基百科,自由的百科全书

这是本页的一个历史版本,由Vanished user 1929210留言 | 贡献2016年9月21日 (三) 03:59编辑。这可能和当前版本存在着巨大的差异。

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*')
    local n = #list - 1
    
    math.randomseed(os.time())
    local r = math.random(n) + 1
    
    return mw.text.trim(list[r])
end

return func