Module:R from fictional object multi/sandbox
Appearance
![]() | This is the module sandbox page for Module:R from fictional object multi (diff). See also the companion subpage for test cases (run). |
![]() | This module depends on the following other modules: |
Module:R from fictional object multi is used by {{R from fictional character}}, {{R from fictional element}} and {{R from fictional location}} to handle multiple series tagged with the same redirect.
Usage
{{#invoke:R from fictional object multi|main|category=|1=|2=|3=|4=|5=|6=|7=|8=|sort=}}
Parameter list
Parameter | Explanation |
---|---|
1...8
|
Positional or numbered parameters for each series name. |
category
|
The redirect category scheme to be used. |
sort
|
An optional sort key for the category. |
local getArgs = require('Module:Arguments').getArgs
categories = ""
local p = {}
local function createCategory(objectType, name, sort)
if (sort) then
categories = categories .. "[[Category:" .. name .. " " .. objectType .. " redirects to lists|" .. sort .. "]]"
else
categories = categories .. "[[Category:" .. name .. " " .. objectType .. " redirects to lists]]"
end
end
local function createLocationCategory(name, sort)
if (sort) then
categories = categories .. "[[Category:" .. name .. " location redirects|" .. sort .. "]]"
else
categories = categories .. "[[Category:" .. name .. " location redirects]]"
end
end
local function _main(objectType, args)
if (objectType == "location") then
for i = 1, 10 do
if (args[i]) then
createLocationCategory(args[i], args["sort"])
end
end
else
for i = 1, 10 do
if (args[i]) then
createCategory(objectType, args[i], args["sort"])
end
end
end
return categories
end
function p.character(frame)
local args = getArgs(frame)
return _main("character", args)
end
function p.element(frame)
local args = getArgs(frame)
return _main("element", args)
end
function p.location(frame)
local args = getArgs(frame)
return _main("location", args)
end
return p