Difference between revisions of "Module:Map credits"
m (Update qmark_langs) |
m |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
− | local creditsData = | + | local creditsData = mw.loadData("Module:Map credits/data") |
function format_credit(link, link_type, link_name) | function format_credit(link, link_type, link_name) | ||
Line 52: | Line 52: | ||
local credits = creditsData | local credits = creditsData | ||
local map_credits = credits[map] or credits._default | local map_credits = credits[map] or credits._default | ||
− | + | local output = {} | |
− | local output = | ||
for i, credit in ipairs(map_credits) do | for i, credit in ipairs(map_credits) do | ||
Line 60: | Line 59: | ||
local link_type = options == "nolink" and "nolink" or (credit[3] or "") | local link_type = options == "nolink" and "nolink" or (credit[3] or "") | ||
− | output | + | table.insert(output, format_credit(link, link_type, name)) |
− | |||
end | end | ||
− | return output | + | return table.concat(output, separator) |
end | end | ||
return p | return p |
Latest revision as of 20:55, 30 September 2024
Documentation for Map credits
Intended for use in the {{map infobox}}
and other tables. Not compatible with custom maps. When adding map credits, include the creator's name exactly as it appears in the in-game credits (see File:tf_english.txt).
Adding more maps
- Edit Module:Map credits/data.
Usage
{{map credits}}
always defaults to Valve, so there's no need to add Valve-made maps to this template.{{map credits|ctf_turbine}}
produces: Flobster{{map credits|cp_egypt_final}}
produces: Sean "Heyo" Cutino{{map credits|cp_egypt_final|options=nolink}}
produces: Sean "Heyo" Cutino{{map credits|rd_asteroid}}
produces: Valve{{map credits|pass_brickyard}}
produces: Valve
Bad Robot
Escalation Studios{{map credits|zi_devastation_final1|separator=, }}
produces: Jordan "Ismaciodismorphus" La Rose, Harry "Harry" Colquhoun, Liam "Diva Dan" Moffitt, Aeon "Void" Bollig, Alex "FGD5" Stewart
Syntax
{{map credits|<file name>|separator=<separator>|options=<options>|override=<override>}}
- <file name> unnamed parameter 1
- Map file name, exactly as it is written in-game.
- (optional) <separator>
- Separator for maps with multiple people credited. Defaults to
<br>
.
- (optional) <options>
- Additional rendering options:
nolink
- Disables rendering of links (Steam profile URL, Wikipedia links, etc.).
local p = {} local creditsData = mw.loadData("Module:Map credits/data") function format_credit(link, link_type, link_name) local if_lang = mw.getCurrentFrame():expandTemplate{title="If lang"} local qmark_langs = { ["/ar"] = { opening = " «", closing = "» " }, ["/cs"] = { opening = " „", closing = "“ " }, ["/es"] = { opening = " «", closing = "» " }, ["/de"] = { opening = " „", closing = "“ " }, ["/fr"] = { opening = " « ", closing = " » " }, ["/ja"] = { opening = "「", closing = "」" }, ["/pl"] = { opening = " „", closing = "” " }, ["/ro"] = { opening = " „", closing = '” ' }, ["/ru"] = { opening = " «", closing = "» " } } local qmark = qmark_langs[if_lang] if qmark then local openingMark = qmark.opening local closingMark = qmark.closing local openingIndex, closingIndex = link_name:find(' "'), link_name:find('" ', 2) if openingIndex and closingIndex then link_name = link_name:gsub(' "', openingMark, 1) link_name = link_name:gsub('" ', closingMark, 1) end end -- Link types local formats = { ["nolink"] = link_name, ["yeslink"] = link, ["wikitext"] = "[[%s" .. if_lang .. "|%s]]", ["steam"] = "[https://steamcommunity.com/profiles/%s %s]", ["external"] = "[%s %s]", ["wikipedia"] = "[[w:%s|%s]]" -- TODO: figure out how to make this thing translatable. Use dictionary? } local format = formats[link_type] or link_name return string.format(format, link, link_name) end function p.credits(f) local args = f.args local map = args[1] local separator = args.separator ~= "" and args.separator or "<br>" local options = args.options ~= "" and args.options or "" local override = args.override ~= "" and args.override or "" local credits = creditsData local map_credits = credits[map] or credits._default local output = {} for i, credit in ipairs(map_credits) do local name = override ~= "" and override or credit[1] local link = credit[2] or "" local link_type = options == "nolink" and "nolink" or (credit[3] or "") table.insert(output, format_credit(link, link_type, name)) end return table.concat(output, separator) end return p