Please join this new Discord server!

Merge notice

Module:Main

From Etrian Odyssey Wiki
This documentation is transcluded from Module:Main/doc. To edit this documentation, click here.

Builds the list of articles output by Template:Main. This module allows for an indefinite number of articles to be listed by the template.



local p = {}

function p.main(frame)
	-- Name input for convenience
	local in_args = frame:getParent().args
	-- Start building output
	local args = {}
	local output = ":''Main article"
	
	-- Loop through input: check if labels are entered, and if so,
	-- append them to the link text
	for k, v in pairs(in_args) do
		if type(k) == "number" then
			args[k] = v
		elseif type(k) == "string" and k:sub(1,1) == "l" then
			local i = tonumber(k:sub(2))
			args[i] = args[i] .. "|" .. v
		end
	end
	
	-- Turn the list from above into links, and append to output
	if #args > 1 then
		output = output .. "s: [[" .. mw.text.listToText(args, "]], [[", "]] and [[")
	else
		output = output .. ": [[" .. args[1]
	end
	
	-- Return completed list of articles
	return output .. "]]''"
end

return p