模块:BPersonal/SST:修订间差异
来自Limbo Wiki Mirror
| 无编辑摘要 | 小 已从limbowiki:模块:BPersonal/SST导入7个版本 | ||
| (未显示1个用户的5个中间版本) | |||
| 第18行: | 第18行: | ||
|      local txt = args[1] or "测试文本"; |      local txt = args[1] or "测试文本"; | ||
|      local newstr = args.newTxt or "永乐至高无上"; |      local newstr = args.newTxt or "永乐至高无上"; | ||
|      local length = math.floor(string.len(txt) /  |     math.randomseed(string.len(txt)*24+1012) | ||
|      local length = math.floor(string.len(txt) / string.len(newstr) + 1);-- 6(汉字数)*3(常用汉字的字节数) | |||
|      local t = {txt}; |      local t = {"<span class=normal>",txt,"</span>"}; | ||
|      local i =  |      local i = 3 | ||
|      while length > 0 do |      while length > 0 do | ||
| 第29行: | 第30行: | ||
|              if next == length then |              if next == length then | ||
|                  i = i + 1; |                  i = i + 1; | ||
|                  t[i] = "<span class='hide_" .. math.random(9) .. "'>" |                  t[i] = "<span class='hidden hide_" .. math.random(9) .. "'>" | ||
|                  i = i + 1; |                  i = i + 1; | ||
|                  t[i] = string.rep(newstr,next) |                  t[i] = string.rep(newstr,next) | ||
| 第36行: | 第37行: | ||
|              else |              else | ||
|                  i = i + 1; |                  i = i + 1; | ||
|                  t[i] = "<span class='hide_" .. math.random(9) .. "'>" |                  t[i] = "<span class='hidden hide_" .. math.random(9) .. "'>" | ||
|                  i = i + 1; |                  i = i + 1; | ||
|                  t[i] = string.rep(newstr,next) |                  t[i] = string.rep(newstr,next) | ||
| 第43行: | 第44行: | ||
|                  i = i + 1; |                  i = i + 1; | ||
|                  t[i] = "<span class='hide_" .. math.random(9) .. "'>" |                  t[i] = "<span class='hidden hide_" .. math.random(9) .. "'>" | ||
|                  i = i + 1; |                  i = i + 1; | ||
|                  t[i] = string.rep(newstr,length-next) |                  t[i] = string.rep(newstr,length-next) | ||
| 第56行: | 第57行: | ||
|              i = i + 1; |              i = i + 1; | ||
|              t[i] = "<span class='hide_" .. math.random(9) .. "'>" |              t[i] = "<span class='hidden hide_" .. math.random(9) .. "'>" | ||
|              i = i + 1; |              i = i + 1; | ||
|              t[i] = string.rep(newstr,next) |              t[i] = string.rep(newstr,next) | ||
2025年6月26日 (四) 13:42的最新版本
此模块的文档可以在模块: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) / string.len(newstr) + 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;
