local description =
local errorMessages =
local errors =
local p =
--Local function which is used to create an error message.--local function createErrorMsg(errorText) local errorMsg = '
Error: ' .. errorText .. '.' table.insert(errors, errorMsg)end--Local function which gets the series list from either the numbered (positional) or named parameters,and checks if the number of series parameters match the value of parts - creates an error message if they aren't.Returns the series list or nil.--local function getSeriesList(parts, args) local seriesList =
parts = parts - 1 if (parts < 1) then parts = 1 end for i = 1, parts do if (args[i] or args["series" .. i]) then seriesList[i] = args[i] or args["series" .. i] else createErrorMsg(string.format(errorMessages["MISSING_VALUE"], i)) return nil end end return seriesListend
--Local function which checks if the parameters used are correct.Creates an error message if they aren't.--local function isArgValidNumber(name, value) if (value) then if (tonumber(value)) then return tonumber(value) else createErrorMsg(string.format(errorMessages["NOT_A_NUMBER"], name)) return nil end else createErrorMsg(string.format(errorMessages["MISSING_VALUE"], name)) return nil endend
--Local function which is used to handle the actual main proccess.--local function _main(args) local parts = isArgValidNumber("parts", args.parts) local currentPart = isArgValidNumber("part", args.part)
-- If missing parts or current part values, show an error. if (not parts or not (currentPart or parts
local seriesList = getSeriesList(parts, args)
-- If missing series parts, show an error. if (not seriesList) then -- Error message handling. return table.concat(errors) end
if (parts
local text = string.format(description[parts][currentPart], seriesList[1], seriesList[2], seriesList[3], seriesList[4], seriesList[5]) if (args.no_hr) then return text else return "
--part= — required; The crossover part number of the current episode. -- |parts= — required; The number of total crossover episodes. -- |no_hr= — optional; Any value will disable the addition of the
return p