Module:Link

From para.wiki
Revision as of 05:17, 27 January 2019 by Anonymous
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Link/doc

local p = {}

local function link(x, y, note)
	local inner
	if note == nil then
		inner = x .. "|" .. y
	elseif note:sub(1, 1) == "&" then
		inner = x .. "|" .. y .. " " .. note
	else
		inner = x .. "|" .. y .. "]] [[File:" .. note .. "|20x20px|link="
	end
	
	return "[[" .. inner .. "]]"
end

local function Set (list)
	local set = {}
	for _, l in ipairs(list) do set[l] = true end
	return set
end

local metals = {
	aluminum = "Aluminium alt 2.svg",
	aluminium = "Aluminium alt 2.svg",
	antimony = "♁",
	arsenic = "	🜺",
	bismuth = "	🜘",
	boron = "=",
	copper = "Copper symbol.svg",
	silver ="☽",
	sulfur = "🜏",
	magnesium = "⊛",
	gold = "🜚",
	iron = "♂",
	lead = "♄",
	tin = "♃",
	lithium = "Stone symbol.svg",
	zinc = "Zinc-alchemy symbols.svg",
	phosphorous = "Phosphorus symbol.svg",
	platinum = "Platinum-symbol.svg"
}

local planets = {
	venus = "♀",
	jupiter = "♃",
	saturn = "♄",
	uranus = "♅",
	neptune = "♆",
	pluto = "♇",
	mercury = "☿",
	mars = "♂"
}

function p.metal(frame)
	local x = frame.args[1]
	local xlo = x:lower()
	
	if xlo == "mercury" then
		return "[[Mercury (metal)|Mercury ☿]]"
	end
	
	return link(x, x, metals[xlo])
end

function p.planet(frame)
	local x = frame.args[1]
	local xlo = x:lower()
	
	if xlo == "earth" then
		return "[[Earth|Earth 🜨]]"
	else
		return link(x .. " (planet)", x, planets[xlo])
	end
end

local function buildNormal(tag, set)
	return function(frame)
		local x = frame.args[1]
		local xlo = x:lower()
		
		if set[xlo] == nil then
			return link(x, x)
		else
			return link(x .. " (" .. tag .. ")", x)
		end
	end
end

p.god = buildNormal('god', Set {
	
})
p.angel = buildNormal('angel', Set {
	
})
p.demon = buildNormal('demon', Set {
	
})

return p