模块:GlitchText
来自Blockland Wiki
更多操作
此模块的文档可以在模块:GlitchText/doc创建
local p = {}
local glyphs = {
"▓", "▒", "░", "█", "╳", "╱", "╲",
"Ж", "Ψ", "※", "¤", "§", "ø", "þ",
"æ", "µ", "∴", "∵", "⌁", "⌘", "⍉",
"⟁", "⧖", "⨳", "⫷", "⫸", "0", "1",
"7", "x", "_", "∿", "⌬", "⟊"
}
function p.main(frame)
local text = frame.args.text or ""
local i = 0
local output = mw.ustring.gsub(
text,
"[^\r\n]",
function()
i = i + 1
-- 根据原文和字符位置生成稳定的伪随机乱码
local hash = mw.hash.hashValue(
"sha256",
text .. ":" .. i
)
local n = tonumber(
string.sub(hash, 1, 8),
16
) or i
return glyphs[(n % #glyphs) + 1]
end
)
return output
end
return p