Module:Episode nb: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
mNo edit summary |
||
| Line 27: | Line 27: | ||
else |
else |
||
-- Direct call to Ep.getEpisode with the current page name |
-- Direct call to Ep.getEpisode with the current page name |
||
episode = |
episode = Ep.getEpisode{ args = { mw.title.getCurrentTitle().text } } |
||
end |
end |
||
Latest revision as of 21:55, 18 November 2025
| You might want to create a documentation page for this Scribunto module. Editors can experiment in this module's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this module. |
local p = {}
local Ep = require("Module:Episode") -- Import the Episode module
-- Utility function for ordinal suffixes
local function ordinal(n)
local specials = {
[1] = "1st",
[2] = "2nd",
[3] = "3rd",
[21] = "21st",
[22] = "22nd"
}
if specials[n] then
return specials[n]
else
return tostring(n) .. "th"
end
end
function p.main(frame)
local args = frame:getParent().args
-- Episode part
local episode
if args.episode and args.episode ~= "" then
episode = "'''" .. args.episode .. "'''"
else
-- Direct call to Ep.getEpisode with the current page name
episode = Ep.getEpisode{ args = { mw.title.getCurrentTitle().text } }
end
-- Manual or automatic episode description
local manual
if args.manual and args.manual ~= "" then
manual = args.manual
else
local num = tonumber(args[1]) or args[1]
manual = "is the " .. ordinal(num) .. " episode"
end
-- Series and season part
local seriesAbv = frame:expandTemplate{ title = "Series abv", args = { series = args.series or "1" } }
local season = args[2] or ""
local seriesLink = "''[[Stargate " .. seriesAbv .. "]]''"
local seasonLink = "[[Stargate " .. seriesAbv .. " Season " .. season .. "|Season " .. season .. "]]"
-- Final assembly
return episode .. " " .. manual .. " of " .. seriesLink .. " " .. seasonLink .. "."
end
return p