Module:Helixfossilname

From A KoL Wiki
Revision as of 07:48, 6 September 2025 by Gausie (talk | contribs) (Generate helixfossil names using Lua)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Helixfossilname/doc

local p = {}

function p.helixfossil(frame)
    local remaining = 10
    local charset = "abcdefghijklmnopqrstuvwxyz()[];:,.!/?-"
    local parts = {}

    while remaining > 0 do
        local n = math.random(remaining)     -- how many repeats of this char
        remaining = remaining - n

        -- pick one character
        local k = math.random(#charset)
        local ch = charset:sub(k, k)

        -- randomly uppercase (letters only)
        if math.random(0, 1) == 0 and ch:match("%a") then
            ch = mw.ustring.upper(ch)
        end

        -- build in chunks, then concat
        parts[#parts + 1] = string.rep(ch, n)
    end

    local s = table.concat(parts)
    return mw.html.create("span"):wikitext(s)
end

return p