No edit summary |
m (Reverted edits by ThetaSigma23 (talk) to last revision by Tim H) Tag: Rollback |
||
(37 intermediate revisions by 3 users not shown) | |||
Line 8: | Line 8: | ||
local function gamelink(game) |
local function gamelink(game) |
||
game = string.lower(game) |
game = string.lower(game) |
||
− | local link = data[game][' |
+ | local link = data[game]['pagename'] |
− | local |
+ | local shortname = data[game]['shortname'] |
local appendix = '' |
local appendix = '' |
||
if data[game]['appendix'] then appendix = ' ' .. data[game]['appendix'] end |
if data[game]['appendix'] then appendix = ' ' .. data[game]['appendix'] end |
||
− | return string.format("[" .. "[" .. "%s|\'\'%s\'\'%s]]", link, |
+ | return string.format("[" .. "[" .. "%s|\'\'%s\'\'%s]]", link, shortname, appendix) |
end |
end |
||
Line 39: | Line 39: | ||
else |
else |
||
return string.format(' [' .. '[' .. '%s script#%s|script § \"%s\"]]', gamename, scriptsection, scriptsection) |
return string.format(' [' .. '[' .. '%s script#%s|script § \"%s\"]]', gamename, scriptsection, scriptsection) |
||
⚫ | |||
+ | end |
||
+ | |||
+ | local function unused(game, transcriptsection, display) |
||
+ | game = string.lower(game) |
||
+ | local gamename |
||
+ | if data[game]['appendix'] then |
||
+ | gamename = data[game]['title'] .. ' ' .. data[game]['appendix'] |
||
⚫ | |||
+ | gamename = data[game]['shortname'] |
||
⚫ | |||
+ | if display then |
||
+ | return string.format(' [' .. '[Project:Bulletin board/' .. '%s unused dialogue#%s|unused dialogue § \"%s\"]]', gamename, transcriptsection, display) |
||
⚫ | |||
+ | return string.format(' [' .. '[Project:Bulletin board/' .. '%s unused dialogue#%s|unused dialogue § \"%s\"]]', gamename, transcriptsection, transcriptsection) |
||
end |
end |
||
end |
end |
||
Line 61: | Line 76: | ||
local extras = data[game]['extras'] |
local extras = data[game]['extras'] |
||
local extraspage = data[game]['extraspage'] |
local extraspage = data[game]['extraspage'] |
||
− | return string.format(' [' .. '[' .. '%s|%s § \"%s\"]]', extraspage, extras, extrasection) |
+ | return string.format(' [' .. '[' .. '%s#%s|%s § \"%s\"]]', extraspage, extrasection, extras, extrasection) |
end |
end |
||
local function museum(game, museumsection) |
local function museum(game, museumsection) |
||
game = string.lower(game) |
game = string.lower(game) |
||
− | local museumpage = |
+ | local museumpage = data[game]['museumpage'] |
− | local museum = |
+ | local museum = data[game]['museum'] |
return string.format(' [' .. '[' .. '%s#%s|%s § %s]]', museumpage, museumsection, museum, museumsection) |
return string.format(' [' .. '[' .. '%s#%s|%s § %s]]', museumpage, museumsection, museum, museumsection) |
||
end |
end |
||
− | local function |
+ | local function tcrf(game, tcrfsection, tcrfpagelink, tcrfpagedesc) |
game = string.lower(game) |
game = string.lower(game) |
||
− | + | local pagelink |
|
− | local |
+ | local desc |
+ | if tcrfpagelink then |
||
⚫ | |||
+ | pagelink = string.gsub(tcrfpagelink, '%s+', '_') |
||
− | if switch == 'website' |
||
+ | desc = tcrfpagedesc |
||
− | then switchoutput = ', [' .. data[game]['website'] .. ' official website]' |
||
⚫ | |||
⚫ | |||
− | + | pagelink = string.gsub(data[game]['title'], '%s+', '_') |
|
− | + | desc = tcrfsection |
|
⚫ | |||
− | else switchoutput = ', ' .. switch |
||
end |
end |
||
+ | local title = data[game]['title'] |
||
⚫ | |||
+ | return string.format(', [' .. 'https://tcrf.net/%s#%s %s on The Cutting Room Floor]', pagelink, string.gsub(tcrfsection, '%s+', '_'), desc) |
||
− | return switchoutput |
||
end |
end |
||
Line 92: | Line 105: | ||
local args = getArgs(frame) |
local args = getArgs(frame) |
||
− | local |
+ | local game = args['game'] or args[1] |
+ | |||
− | if (args['game'] or args[1]) then gamesec = gamelink((args['game'] or args[1])) end |
||
+ | local gamesec = gamelink(game) |
||
+ | |||
⚫ | |||
+ | if args['mission'] |
||
⚫ | |||
− | + | then contentsec = missionlink(args['mission'], args['display']) |
|
+ | elseif args['file'] |
||
⚫ | |||
⚫ | |||
− | local filesec = '' |
||
+ | elseif args['script'] |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | elseif args['unused'] |
||
− | local onscreentextsec = '' |
||
− | + | then contentsec = unused(game, args['unused'], args['display']) |
|
+ | elseif args['menu'] |
||
⚫ | |||
+ | then contentsec = menu(game, args['menu'], args['display']) |
||
− | local scriptsec = '' |
||
+ | elseif args['extras'] |
||
⚫ | |||
⚫ | |||
− | |||
+ | elseif args['museum'] |
||
− | local menusec = '' |
||
− | + | then contentsec = museum(game, args['museum']) |
|
+ | elseif args['tcrf'] |
||
− | |||
+ | then contentsec = tcrf(game, args['tcrf'], args['pagelink'], args['pagedesc']) |
||
− | local extrasec = '' |
||
+ | elseif args['guide'] |
||
⚫ | |||
⚫ | |||
− | |||
⚫ | |||
− | local museumsec = '' |
||
− | + | then contentsec = ', ' .. data[game]['manual'][args['region']] .. ', p. ' .. args['manual'] |
|
+ | elseif args[2] or args['other'] |
||
− | |||
+ | then contentsec = ', ' .. (args[2] or args['other']) |
||
− | local switchsec = '' |
||
+ | end |
||
− | if args[2] then switchsec = switchfeatures(args[2], (args['game'] or args[1]), args['version'], args['brand'], args['p']) end |
||
+ | |||
− | |||
local refname = '' |
local refname = '' |
||
if args['name'] then refname = ' name="' .. args['name'] .. '"' end |
if args['name'] then refname = ' name="' .. args['name'] .. '"' end |
||
− | local citeoutput = '<ref' .. refname ..'>' .. gamesec .. |
+ | local citeoutput = '<ref' .. refname ..'>' .. gamesec .. contentsec .. '</ref>' |
return frame:preprocess(citeoutput) |
return frame:preprocess(citeoutput) |
||
Line 128: | Line 144: | ||
return cite |
return cite |
||
+ | |||
+ | --[[Category:Modules]] |
Revision as of 09:34, 30 August 2020
This page contains Lua code for Template:Cite.
-- This module implements cite templates.
-- See {{cite}} for the base template and a documentation.
local cite = {}
local getArgs = require('Dev:Arguments').getArgs
local data = mw.loadData('Module:Codename')
-- Helper functions
local function gamelink(game)
game = string.lower(game)
local link = data[game]['pagename']
local shortname = data[game]['shortname']
local appendix = ''
if data[game]['appendix'] then appendix = ' ' .. data[game]['appendix'] end
return string.format("[" .. "[" .. "%s|\'\'%s\'\'%s]]", link, shortname, appendix)
end
local function missionlink(mission, display)
if display then
return string.format(', \"[' .. '[' .. '%s|%s]]\"', mission, display)
else
return string.format(', \"[' .. '[' .. '%s]]\"', mission)
end
end
local function gamefile(file)
return string.format(', file: <code>%s</code>', file)
end
local function script(game, scriptsection, display)
game = string.lower(game)
local gamename
if data[game]['appendix'] then
gamename = data[game]['title'] .. ' ' .. data[game]['appendix']
else
gamename = data[game]['shortname']
end
if display then
return string.format(' [' .. '[' .. '%s script#%s|script § \"%s\"]]', gamename, scriptsection, display)
else
return string.format(' [' .. '[' .. '%s script#%s|script § \"%s\"]]', gamename, scriptsection, scriptsection)
end
end
local function unused(game, transcriptsection, display)
game = string.lower(game)
local gamename
if data[game]['appendix'] then
gamename = data[game]['title'] .. ' ' .. data[game]['appendix']
else
gamename = data[game]['shortname']
end
if display then
return string.format(' [' .. '[Project:Bulletin board/' .. '%s unused dialogue#%s|unused dialogue § \"%s\"]]', gamename, transcriptsection, display)
else
return string.format(' [' .. '[Project:Bulletin board/' .. '%s unused dialogue#%s|unused dialogue § \"%s\"]]', gamename, transcriptsection, transcriptsection)
end
end
local function menu(game, transcriptsection, display)
game = string.lower(game)
local gamename
if data[game]['appendix'] then
gamename = data[game]['title'] .. ' ' .. data[game]['appendix']
else
gamename = data[game]['shortname']
end
if display then
return string.format(' [' .. '[' .. '%s menu transcript#%s|menu § \"%s\"]]', gamename, transcriptsection, display)
else
return string.format(' [' .. '[' .. '%s menu transcript#%s|menu § \"%s\"]]', gamename, transcriptsection, transcriptsection)
end
end
local function extras(game, extrasection)
game = string.lower(game)
local extras = data[game]['extras']
local extraspage = data[game]['extraspage']
return string.format(' [' .. '[' .. '%s#%s|%s § \"%s\"]]', extraspage, extrasection, extras, extrasection)
end
local function museum(game, museumsection)
game = string.lower(game)
local museumpage = data[game]['museumpage']
local museum = data[game]['museum']
return string.format(' [' .. '[' .. '%s#%s|%s § %s]]', museumpage, museumsection, museum, museumsection)
end
local function tcrf(game, tcrfsection, tcrfpagelink, tcrfpagedesc)
game = string.lower(game)
local pagelink
local desc
if tcrfpagelink then
pagelink = string.gsub(tcrfpagelink, '%s+', '_')
desc = tcrfpagedesc
else
pagelink = string.gsub(data[game]['title'], '%s+', '_')
desc = tcrfsection
end
local title = data[game]['title']
return string.format(', [' .. 'https://tcrf.net/%s#%s %s on The Cutting Room Floor]', pagelink, string.gsub(tcrfsection, '%s+', '_'), desc)
end
-- Produces the cite template.
function cite.main(frame)
local args = getArgs(frame)
local game = args['game'] or args[1]
local gamesec = gamelink(game)
local contentsec = ''
if args['mission']
then contentsec = missionlink(args['mission'], args['display'])
elseif args['file']
then contentsec = gamefile(args['file'])
elseif args['script']
then contentsec = script(game, args['script'], args['display'])
elseif args['unused']
then contentsec = unused(game, args['unused'], args['display'])
elseif args['menu']
then contentsec = menu(game, args['menu'], args['display'])
elseif args['extras']
then contentsec = extras(game, args['extras'])
elseif args['museum']
then contentsec = museum(game, args['museum'])
elseif args['tcrf']
then contentsec = tcrf(game, args['tcrf'], args['pagelink'], args['pagedesc'])
elseif args['guide']
then contentsec = ", ''" .. data[game]['guide']['title'] .. "'', p. " .. args['guide']
elseif args['manual']
then contentsec = ', ' .. data[game]['manual'][args['region']] .. ', p. ' .. args['manual']
elseif args[2] or args['other']
then contentsec = ', ' .. (args[2] or args['other'])
end
local refname = ''
if args['name'] then refname = ' name="' .. args['name'] .. '"' end
local citeoutput = '<ref' .. refname ..'>' .. gamesec .. contentsec .. '</ref>'
return frame:preprocess(citeoutput)
end
return cite
--[[Category:Modules]]