Module:NotConfusedWith

From The Blockheads Wiki
Revision as of 20:19, 17 September 2026 by FloofyPlasma (talk | contribs) (Created page with "local p = {} function p.main(frame) local args = frame:getParent().args local items = {} for i = 1, 99 do local arg = args[i] if arg and arg:match("%S") then table.insert(items, "" .. arg .. "") else break end end if #items == 0 then return "" end if #items == 1 then return "Not to be confused with " .. items[1] .. "." end -- Join with comm...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

local p = {}

function p.main(frame)
    local args = frame:getParent().args
    local items = {}
    
    for i = 1, 99 do
        local arg = args[i]
        if arg and arg:match("%S") then
            table.insert(items, "[[" .. arg .. "]]")
        else
            break
        end
    end
    
    if #items == 0 then
        return ""
    end
    
    if #items == 1 then
        return "Not to be confused with " .. items[1] .. "."
    end
    
    -- Join with commas, add "and" before last item
    local result = "Not to be confused with " .. table.concat(items, ", ", 1, #items - 1)
    result = result .. ", and " .. items[#items] .. "."
    
    return result
end

return p