Module:Episode nb: Difference between revisions
Appearance
Content deleted Content added
Created page with "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 par..." |
mNo edit summary |
||
| Line 9: | Line 9: | ||
[3] = "3rd", |
[3] = "3rd", |
||
[21] = "21st", |
[21] = "21st", |
||
[22] = "22nd" |
[22] = "22nd", |
||
[23] = "23rd" |
|||
} |
} |
||
if specials[n] then |
if specials[n] then |
||
Revision as of 19:45, 8 December 2025
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",
[23] = "23rd"
}
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