模块:BPersonal/SST
来自Limbo Wiki Mirror
此模块的文档可以在模块:BPersonal/SST/doc创建
local frame;
local getArgs = require('Module:Arguments').getArgs;
local p = {}
function makeInvokeFunc(funcName)
    return function(frame)
        local args = getArgs(frame)
        return p[funcName](args)
    end
end
p.f1 = makeInvokeFunc('_RandomTextToNewText')
function p._RandomTextToNewText(args)
    frame = mw.getCurrentFrame();
    local txt = args[1] or "测试文本";
    local newstr = args.newTxt or "永乐至高无上";
    math.randomseed(string.len(txt)*24+1012)
    local length = math.floor(string.len(txt) / 18 + 1);-- 6(汉字数)*3(常用汉字的字节数)
    local t = {"<span class=normal>",txt,"</span>"};
    local i = 3
    while length > 0 do
        
        if length < 4 then
            local next = math.random(length);
            if next == length then
                i = i + 1;
                t[i] = "<span class='hidden hide_" .. math.random(9) .. "'>"
                i = i + 1;
                t[i] = string.rep(newstr,next)
                i = i + 1;
                t[i] = "</span>"
            else
                i = i + 1;
                t[i] = "<span class='hidden hide_" .. math.random(9) .. "'>"
                i = i + 1;
                t[i] = string.rep(newstr,next)
                i = i + 1;
                t[i] = "</span>"
                i = i + 1;
                t[i] = "<span class='hidden hide_" .. math.random(9) .. "'>"
                i = i + 1;
                t[i] = string.rep(newstr,length-next)
                i = i + 1;
                t[i] = "</span>"
            end
            length = 0;
        else
            local next = 1 + math.random(3);
            length = length - next;
            i = i + 1;
            t[i] = "<span class='hidden hide_" .. math.random(9) .. "'>"
            i = i + 1;
            t[i] = string.rep(newstr,next)
            i = i + 1;
            t[i] = "</span>"
        end
    end
    return table.concat(t);
end
return p;
