This wiki has had no edits or log actions made within the last 45 days and has been automatically marked as inactive. If you would like to prevent this wiki from being closed, please start showing signs of activity here. If there are no signs of this wiki being used within the next 15 days, this wiki will be closed in accordance to the Dormancy Policy (which all wiki founders accept when requesting a wiki). If this wiki is closed and no one reopens it 135 days from now, this wiki will become eligible for deletion. Note: If you are a bureaucrat, you can go to Special:ManageWiki and uncheck "inactive" yourself.
Module:Ep
From Queen's Court Games
Documentation for this module may be created at Module:Ep/doc
local p = {}
-- function to retrieve and format the episode name
function p.ep(frame)
-- convert the input into the standardized epCode
local ep = frame.args[1]
local epMatcher = require('Module:Ep/Matcher')
local epCode = epMatcher.matchCode(ep)
-- error message if code doesn't exist
if epCode == '0x00' then
local errorMsg = "<span style=\"color:red; font-weight: bold;\">Undefined Episode</span>"
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
local subpageText = title.subpageText
if namespace == 0 then
errorMsg = errorMsg .. "[[Category:Ep calls to undefined episodes]]"
elseif subpageText == 'test' or subpageText == 'testcases' then
errorMsg = errorMsg .. "<small> would be in [[:Category:Ep calls to undefined episodes]]</small>"
end
return errorMsg
end
-- get the title and pagename for that epCode
local epInfo = require('Module:Ep/Info')
local epName = epInfo.title(epCode)
local pageName = epInfo.pagename(epCode)
-- epCode (w/special formatting, if any)
local epCodeFormatted = epInfo.epCodeFormatted(epCode)
-- formatting with the various parameters of {{ep}}
local text = frame.args["text"] or nil
local nolink = frame.args["nolink"] or nil
local plain = frame.args["plain"] or nil
local hide = frame.args["hide"] or nil
local noshow = frame.args["noshow"] or nil
local epValue
if pageName:find("Talks Machina Special") and exists(noshow) then
epName = split(pageName, ': ')[2]
elseif pageName:find("Talks Machina") and exists(noshow) then
epName = pageName:gsub('Talks Machina ', '#')
elseif exists(noshow) then
epName = pageName
end
if exists(text) then
epValue = pageName .. "|" .. text
elseif pageName ~= epName and not exists(nolink) then
epValue = pageName .. '|' .. epName
elseif exists(nolink) then
epValue = epName
else
epValue = pageName
end
if exists(nolink) then epValue = epValue
else epValue = "[[" .. epValue .. "]]" end
if not exists(plain) then epValue = '"' .. epValue .. '"' end
local fullEpValue = epValue .. ' ' .. epCodeFormatted
if exists(hide) then return epValue
else return fullEpValue end
end
--function to determine if a string is empty
function exists(s)
return s ~= nil and s ~= ''
end
-- function to split a string at a specified character
function split(s, delimiter)
result = {};
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);
end
return result;
end
return p