Lua kļūda Modulis:Documentation, 388. rinda: message: type error in message cfg.module-sandbox-category (string expected, got nil).

local p = {}

local function getArgNums(args, prefix)
    local nums = {}
    for k, v in pairs(args) do
        local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$')
        if num then table.insert(nums, tonumber(num)) end
    end
    table.sort(nums)
    return nums
end

local function makeLink(link, text)
	if link == nil or link == text then
		return "[[" .. text .. "]]"
	end
	return "[[" .. link .. "|" .. text .. "]]"
end

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Veidne:Vieta'})
	local out = {}
	local tagad
	local result
	
	local replacements = {
		["ASV"]="Amerikas Savienotās Valstis",
		["PSRS"]="Padomju Savienība",
		["Lielbritānija"]="Apvienotā Karaliste",
		["Krievijas impērija"]="Krievijas Impērija"
	}
	
	if not args["1s"] then
		args["1s"] = mw.ustring.gsub(args[1],"^.*$",replacements)
	end
	
	for i, v in ipairs(args) do
		out[#out+1] = makeLink(args[i .. 's'], v)
	end
	local reversed, count = {}, #out
	for i = 1, count do
		reversed[i] = out[count + 1 - i]
	end

	local nums = getArgNums(args,'td')
	for i = #nums, 1, -1 do
		local num = nums[i]
		local tdlink = args['td' .. num .. 's'] or args['td' .. num]
		local tdtext = args['td' .. num]
		tdout[#tdout+1] = makeLink(tdlink,tdtext)
	end
	
	if args.td then
		tagad = ' <span style="white-space:nowrap;">(tagad ' .. frame:expandTemplate{ title="flag", args = { args.td } } .. ')</span>'
	end

	local result = frame:expandTemplate{ title="flaga", args = { args[1], args.flagvar } } .. ' ' .. mw.text.listToText( reversed, ', ', ', ' )
					.. mw.text.listToText( tdout, ', ', ', ' ) .. (tagad or '')

	return result
end

return p