Jump to content

Module:R from fictional object multi/sandbox

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Gonnym (talk | contribs) at 12:04, 19 December 2019 (Create sandbox version of Module:R from fictional object multi). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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