跳转到内容
打开/关闭菜单
  • 450 条目
  • 804 文件
  • 22 用户
  • 9052 编辑
Blockland Wiki
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

模块:GlitchText:修订间差异

来自Blockland Wiki
创建页面,内容为“ 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…”
 
无编辑摘要
 
第2行: 第2行:
local p = {}
local p = {}


local glyphs = {
local function mask(text)
     "▓", "▒", "░", "█", "╳", "╱", "╲",
     return (mw.ustring.gsub(text, "[^%s]", "█"))
    "Ж", "Ψ", "※", "¤", "§", "ø", "þ",
end
    "æ", "µ", "∴", "∵", "⌁", "⌘", "⍉",
    "⟁", "⧖", "⨳", "⫷", "⫸", "0", "1",
    "7", "x", "_", "∿", "⌬", "⟊"
}


function p.main(frame)
function p.main(frame)
     local text = frame.args.text or ""
     local text = frame.args.text or frame.args[1] or ""
    local i = 0


     local output = mw.ustring.gsub(
     local span = mw.html.create("span")
         text,
         :addClass("krnk-glitch")
         "[^\r\n]",
         :attr("data-text", text)
         function()
         :wikitext(mask(text))
            i = i + 1


            -- 根据原文和字符位置生成稳定的伪随机乱码
    return tostring(span)
            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
end


return p
return p

2026年10月22日 (四) 12:15的最新版本

此模块的文档可以在模块:GlitchText/doc创建


local p = {}

local function mask(text)
    return (mw.ustring.gsub(text, "[^%s]", "█"))
end

function p.main(frame)
    local text = frame.args.text or frame.args[1] or ""

    local span = mw.html.create("span")
        :addClass("krnk-glitch")
        :attr("data-text", text)
        :wikitext(mask(text))

    return tostring(span)
end

return p