Module:GetEmoji

From Heterodontosaurus Balls
Revision as of 19:18, 9 July 2026 by Heterodontosaurus (talk | contribs) (Replaced content with "--[[ 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...")

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