Module:GetEmoji
From Heterodontosaurus Balls
Documentation for this module may be created at Module:GetEmoji/doc
--[[
This module is intended to provide an alt text (text that appears when the image doesn't load or is copied to a plaintext editor) for the image on {{I}}, and to provide an appropriate link to the character when the image is clicked. But it is not in use because for some reason Navbox/EU and Navbox/Germany (and the pages that uses them) crashes when the appropriate version of {{I}} is implemented.
]]
local p = {}
--[[
This table provides the alt text and link destination for each code used in the GetIcon template. For codes not listed in the table, the alt text and link destination is equal to the code itself.
Each line has the following form:
{"name", "alt text"}
In the alt text, put the flag emoji for the countryball, if there is one. In the link destination, provide the name of the article/page which describes the character for the code.
Link handling is already handled in the template, so there is no need to do it again.
]]
local codes = {
{"0ball", "π"},
{"404", "βΉ"},
{"64", "π’"},
{"Albania", "π¦π±"},
{"Algeria", "π©πΏ"},
{"AncEgypt", "π"},
{"Andorra", "π¦π©"},
{"Angola", "π¦π΄"},
{"Armchair base", "πΊ"},
{"Ball base", "βοΈ"},
{"Baptist base", "π§"},
{"Big base", "π
±οΈ"},
{"Book base", "π"},
{"Brick base", "π§±"},
{"China", "ποΈ"},
{"Cube base", "π¦"},
{"Fat base", "π₯©"},
{"Flag alt base", "π³οΈ"},
{"Flag base", "β³οΈ"},
{"FSA", "π©"},
{"Germania", "π‘οΈ"},
{"Germany", "π©πͺ"},
{"Halo base", "π"},
{"Jomon", "πΊ"},
{"Language base", "π¬"},
{"Nine Li", "βοΈ"},
{"Paleolithic Japan", "πΎ"},
{"Snake base", "π"},
{"Sumer", "π"},
{"Tangle base", "πͺ"},
{"Triangle base", "πΊ"}
}
--[[
code
This function returns the corresponding alt text or the link destination for the
specified code.
Usage:
{{#invoke:GetEmoji|code|specified_code|link_or_alt}}
Specify the code in the first parameter. If the second parameter is equal to
"alt", the function will return the corresponding alt text for the code.
Otherwise, the function will return the link destination for the code.
If the code doesn't exist in the codes table (because the filename for the Dia
template is exactly equal to the character's name), the code itself is returned,
regardless of the second parameter.
]]
function p.code( frame )
c = mw.text.trim(frame.args[1])
for i, a in ipairs(codes) do
if a[1] == c then
if frame.args[2] == "alt" then
-- Return alt text if specified
if a[2] then
return a[2]
else
return "(Icon)" -- If no alt text is specified, return "(Icon)"
end
else
-- Return the link destination (if available)
return a[3] or c -- If no link destination, return the code itself
end
end
end
-- If code is not found, return "π³οΈ" as the fallback
return "π³οΈ"
end
return p
