模块:BPersonal/SST:修订间差异
来自Limbo Wiki Mirror
创建页面,内容为“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 "永乐至高无上"; local length = mat…” |
无编辑摘要 |
||
| 第25行: | 第25行: | ||
while length > 0 do | while length > 0 do | ||
if length < | if length < 4 then | ||
local next = math.random(length); | local next = math.random(length); | ||
if next == length then | if next == length then | ||
| 第52行: | 第52行: | ||
length = 0; | length = 0; | ||
else | else | ||
local next = | local next = 1 + math.random(3); | ||
length = length - next; | length = length - next; | ||
2024年10月12日 (六) 15:18的版本
此模块的文档可以在模块: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 "永乐至高无上";
local length = math.floor(string.len(txt) / 18 + 1);-- 6(汉字数)*3(常用汉字的字节数)
local t = {txt};
local i = 1
while length > 0 do
if length < 4 then
local next = math.random(length);
if next == length then
i = i + 1;
t[i] = "<span class='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='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='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='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;
