Difference between revisions of "Module:Franchise total episodes"
Jump to navigation
Jump to search
blackwiki>TheTVExpert |
blackwiki>TheTVExpert |
||
| Line 206: | Line 206: | ||
local year, month, day | local year, month, day | ||
| + | local day1=0 | ||
| + | local day2=0 | ||
| + | local day3=0 | ||
| + | local day4=0 | ||
| + | local day5=0 | ||
| + | local day1D=0 | ||
| + | local day2D=0 | ||
| + | local day3D=0 | ||
| + | local day4D=0 | ||
| + | local day5D=0 | ||
year = math.max(L1_1,L2_1,L3_1,L4_1,L5_1,D1Y,D2Y,D3Y,D4Y,D5Y) | year = math.max(L1_1,L2_1,L3_1,L4_1,L5_1,D1Y,D2Y,D3Y,D4Y,D5Y) | ||
month = monthName(math.max(L1_2,L2_2,L3_2,L4_2,L5_2,D1M,D2M,D3M,D4M,D5M)) | month = monthName(math.max(L1_2,L2_2,L3_2,L4_2,L5_2,D1M,D2M,D3M,D4M,D5M)) | ||
| − | day = math.max( | + | |
| + | if(monthNum(month) == L1_2) then day1=L1_3 end | ||
| + | if(monthNum(month) == L2_2) then day2=L2_3 end | ||
| + | if(monthNum(month) == L3_2) then day3=L3_3 end | ||
| + | if(monthNum(month) == L4_2) then day4=L4_3 end | ||
| + | if(monthNum(month) == L5_2) then day5=L5_3 end | ||
| + | if(monthNum(month) == D1M) then day1D=D1D end | ||
| + | if(monthNum(month) == D2M) then day2D=D2D end | ||
| + | if(monthNum(month) == D3M) then day3D=D3D end | ||
| + | if(monthNum(month) == D4M) then day4D=D4D end | ||
| + | if(monthNum(month) == D5M) then day5D=D5D end | ||
| + | |||
| + | day = math.max(day1,day2,day3,day4,day5,day1D,day2D,day3D,day4D,day5D) | ||
local S1 = tonumber(frame:expandTemplate{title='Template parameter value',args={S1,T2,1,T3,1}}) | local S1 = tonumber(frame:expandTemplate{title='Template parameter value',args={S1,T2,1,T3,1}}) | ||
Revision as of 16:29, 28 April 2020
Implements {{Franchise total episodes}}
local p = {};
local monthName = function(I1)
if(I1 == 1) then return 'January' end
if(I1 == 2) then return 'February' end
if(I1 == 3) then return 'March' end
if(I1 == 4) then return 'April' end
if(I1 == 5) then return 'May' end
if(I1 == 6) then return 'June' end
if(I1 == 7) then return 'July' end
if(I1 == 8) then return 'August' end
if(I1 == 9) then return 'September' end
if(I1 == 10) then return 'October' end
if(I1 == 11) then return 'November' end
if(I1 == 12) then return 'December' end
if(I1 == 0) then return 0 end
end
local monthNum = function(I1)
if(I1 == 'January') then return 1 end
if(I1 == 'February') then return 2 end
if(I1 == 'March') then return 3 end
if(I1 == 'April') then return 4 end
if(I1 == 'May') then return 5 end
if(I1 == 'June') then return 6 end
if(I1 == 'July') then return 7 end
if(I1 == 'August') then return 8 end
if(I1 == 'September') then return 9 end
if(I1 == 'October') then return 10 end
if(I1 == 'November') then return 11 end
if(I1 == 'December') then return 12 end
return I1
end
p.main = function( frame )
local D1 = mw.getCurrentFrame():getParent().args.D1 or frame.args.D1
if(D1 == nil) then D1 = "none none none none" end
D1 = tostring(D1)
local D2 = mw.getCurrentFrame():getParent().args.D2 or frame.args.D2
if(D2 == nil) then D2 = "none none none none" end
D2 = tostring(D2)
local D3 = mw.getCurrentFrame():getParent().args.D3 or frame.args.D3
if(D3 == nil) then D3 = "none none none none" end
D3 = tostring(D3)
local D4 = mw.getCurrentFrame():getParent().args.D4 or frame.args.D4
if(D4 == nil) then D4 = "none none none none" end
D4 = tostring(D4)
local D5 = mw.getCurrentFrame():getParent().args.D5 or frame.args.D5
if(D5 == nil) then D5 = "none none none none" end
D5 = tostring(D5)
local D1I = mw.getCurrentFrame():getParent().args.D1I or frame.args.D1I or 0
local D2I = mw.getCurrentFrame():getParent().args.D2I or frame.args.D2I or 0
local D3I = mw.getCurrentFrame():getParent().args.D3I or frame.args.D3I or 0
local D4I = mw.getCurrentFrame():getParent().args.D4I or frame.args.D4I or 0
local D5I = mw.getCurrentFrame():getParent().args.D5I or frame.args.D5I or 0
if(D1 ~= 'none none none none') then
local D1N = (frame:expandTemplate{title='Template parameter value',args={D1,"Infobox television",1,"num_episodes"}}+D1I)
D1 = frame:expandTemplate{title='Template parameter value',args={D1,"Episode list",D1N,"OriginalAirDate",1}}
end
if(D2 ~= 'none none none none') then
local D2N = (frame:expandTemplate{title='Template parameter value',args={D2,"Infobox television",1,"num_episodes"}}+D2I)
D2 = frame:expandTemplate{title='Template parameter value',args={D2,"Episode list",D2N,"OriginalAirDate",1}}
end
if(D3 ~= 'none none none none') then
local D3N = (frame:expandTemplate{title='Template parameter value',args={D3,"Infobox television",1,"num_episodes"}}+D3I)
D3 = frame:expandTemplate{title='Template parameter value',args={D3,"Episode list",D3N,"OriginalAirDate",1}}
end
if(D4 ~= 'none none none none') then
local D4N = (frame:expandTemplate{title='Template parameter value',args={D4,"Infobox television",1,"num_episodes"}}+D4I)
D4 = frame:expandTemplate{title='Template parameter value',args={D4,"Episode list",D4N,"OriginalAirDate",1}}
end
if(D5 ~= 'none none none none') then
local D5N = (frame:expandTemplate{title='Template parameter value',args={D5,"Infobox television",1,"num_episodes"}}+D5I)
D5 = frame:expandTemplate{title='Template parameter value',args={D5,"Episode list",D5N,"OriginalAirDate",1}}
end
D1 = string.gsub(D1, ",", "")
D2 = string.gsub(D2, ",", "")
D3 = string.gsub(D3, ",", "")
D4 = string.gsub(D4, ",", "")
D5 = string.gsub(D5, ",", "")
local D1t = {}
local D2t = {}
local D3t = {}
local D4t = {}
local D5t = {}
for substring in D1:gmatch("%w+") do
table.insert(D1t,substring)
end
for substring in D2:gmatch("%w+") do
table.insert(D2t,substring)
end
for substring in D3:gmatch("%w+") do
table.insert(D3t,substring)
end
for substring in D4:gmatch("%w+") do
table.insert(D4t,substring)
end
for substring in D5:gmatch("%w+") do
table.insert(D5t,substring)
end
local L1 = mw.getCurrentFrame():getParent().args.L1 or frame.args.L1
local L2 = mw.getCurrentFrame():getParent().args.L2 or frame.args.L2
local L3 = mw.getCurrentFrame():getParent().args.L3 or frame.args.L3
local L4 = mw.getCurrentFrame():getParent().args.L4 or frame.args.L4
local L5 = mw.getCurrentFrame():getParent().args.L5 or frame.args.L5
local T1 = mw.getCurrentFrame():getParent().args.T1 or 'Aired episodes'
local T2 = 'Infobox television'
local T3 = 'num_episodes'
local S1 = mw.getCurrentFrame():getParent().args.S1 or frame.args.S1
local S2 = mw.getCurrentFrame():getParent().args.S2 or frame.args.S2
local S3 = mw.getCurrentFrame():getParent().args.S3 or frame.args.S3
local S4 = mw.getCurrentFrame():getParent().args.S4 or frame.args.S4
local S5 = mw.getCurrentFrame():getParent().args.S5 or frame.args.S5
local S6 = mw.getCurrentFrame():getParent().args.S6 or frame.args.S6
local S7 = mw.getCurrentFrame():getParent().args.S7 or frame.args.S7
local S8 = mw.getCurrentFrame():getParent().args.S8 or frame.args.S8
local S9 = mw.getCurrentFrame():getParent().args.S9 or frame.args.S9
local S10 = mw.getCurrentFrame():getParent().args.S10 or frame.args.S10
local name = mw.getCurrentFrame():getParent().args.name or frame.args.name
name = tostring(name)
if(name == 'nil') then name = "name" end
local Date = mw.getCurrentFrame():getParent().args.Date or frame.args.Date
local sum = mw.getCurrentFrame():getParent().args.sum or frame.args.sum
local L1_1 = tonumber(frame:expandTemplate{title='Template parameter value',args={L1,T1,1,1,1}})
if(L1_1 == nil) then L1_1 = 0 end
local L1_2 = tonumber(frame:expandTemplate{title='Template parameter value',args={L1,T1,1,2,1}})
if(L1_2 == nil) then L1_2 = 0 end
local L1_3 = tonumber(frame:expandTemplate{title='Template parameter value',args={L1,T1,1,3,1}})
if(L1_3 == nil) then L1_3 = 0 end
local L2_1 = tonumber(frame:expandTemplate{title='Template parameter value',args={L2,T1,1,1,1}})
if(L2_1 == nil) then L2_1 = 0 end
local L2_2 = tonumber(frame:expandTemplate{title='Template parameter value',args={L2,T1,1,2,1}})
if(L2_2 == nil) then L2_2 = 0 end
local L2_3 = tonumber(frame:expandTemplate{title='Template parameter value',args={L2,T1,1,3,1}})
if(L2_3 == nil) then L2_3 = 0 end
local L3_1 = tonumber(frame:expandTemplate{title='Template parameter value',args={L3,T1,1,1,1}})
if(L3_1 == nil) then L3_1 = 0 end
local L3_2 = tonumber(frame:expandTemplate{title='Template parameter value',args={L3,T1,1,2,1}})
if(L3_2 == nil) then L3_2 = 0 end
local L3_3 = tonumber(frame:expandTemplate{title='Template parameter value',args={L3,T1,1,3,1}})
if(L3_3 == nil) then L3_3 = 0 end
local L4_1 = tonumber(frame:expandTemplate{title='Template parameter value',args={L4,T1,1,1,1}})
if(L4_1 == nil) then L4_1 = 0 end
local L4_2 = tonumber(frame:expandTemplate{title='Template parameter value',args={L4,T1,1,2,1}})
if(L4_2 == nil) then L4_2 = 0 end
local L4_3 = tonumber(frame:expandTemplate{title='Template parameter value',args={L4,T1,1,3,1}})
if(L4_3 == nil) then L4_3 = 0 end
local L5_1 = tonumber(frame:expandTemplate{title='Template parameter value',args={L5,T1,1,1,1}})
if(L5_1 == nil) then L5_1 = 0 end
local L5_2 = tonumber(frame:expandTemplate{title='Template parameter value',args={L5,T1,1,2,1}})
if(L5_2 == nil) then L5_2 = 0 end
local L5_3 = tonumber(frame:expandTemplate{title='Template parameter value',args={L5,T1,1,3,1}})
if(L5_3 == nil) then L5_3 = 0 end
local D1Y = tonumber(monthNum(D1t[5]))
if(D1Y == nil) then D1Y = 0 end
local D1M = tonumber(monthNum(D1t[1]))
if(D1M == nil) then D1M = 0 end
local D1D = tonumber(monthNum(D1t[3]))
if(D1D == nil) then D1D = 0 end
local D2Y = tonumber(monthNum(D2t[5]))
if(D2Y == nil) then D2Y = 0 end
local D2M = tonumber(monthNum(D2t[1]))
if(D2M == nil) then D2M = 0 end
local D2D = tonumber(monthNum(D2t[3]))
if(D2D == nil) then D2D = 0 end
local D3Y = tonumber(monthNum(D3t[5]))
if(D3Y == nil) then D3Y = 0 end
local D3M = tonumber(monthNum(D3t[1]))
if(D3M == nil) then D3M = 0 end
local D3D = tonumber(monthNum(D3t[3]))
if(D3D == nil) then D3D = 0 end
local D4Y = tonumber(monthNum(D4t[5]))
if(D4Y == nil) then D4Y = 0 end
local D4M = tonumber(monthNum(D4t[1]))
if(D4M == nil) then D4M = 0 end
local D4D = tonumber(monthNum(D4t[3]))
if(D4D == nil) then D4D = 0 end
local D5Y = tonumber(monthNum(D5t[5]))
if(D5Y == nil) then D5Y = 0 end
local D5M = tonumber(monthNum(D5t[1]))
if(D5M == nil) then D5M = 0 end
local D5D = tonumber(monthNum(D5t[3]))
if(D5D == nil) then D5D = 0 end
local year, month, day
local day1=0
local day2=0
local day3=0
local day4=0
local day5=0
local day1D=0
local day2D=0
local day3D=0
local day4D=0
local day5D=0
year = math.max(L1_1,L2_1,L3_1,L4_1,L5_1,D1Y,D2Y,D3Y,D4Y,D5Y)
month = monthName(math.max(L1_2,L2_2,L3_2,L4_2,L5_2,D1M,D2M,D3M,D4M,D5M))
if(monthNum(month) == L1_2) then day1=L1_3 end
if(monthNum(month) == L2_2) then day2=L2_3 end
if(monthNum(month) == L3_2) then day3=L3_3 end
if(monthNum(month) == L4_2) then day4=L4_3 end
if(monthNum(month) == L5_2) then day5=L5_3 end
if(monthNum(month) == D1M) then day1D=D1D end
if(monthNum(month) == D2M) then day2D=D2D end
if(monthNum(month) == D3M) then day3D=D3D end
if(monthNum(month) == D4M) then day4D=D4D end
if(monthNum(month) == D5M) then day5D=D5D end
day = math.max(day1,day2,day3,day4,day5,day1D,day2D,day3D,day4D,day5D)
local S1 = tonumber(frame:expandTemplate{title='Template parameter value',args={S1,T2,1,T3,1}})
if(S1 == nil) then S1 = 0 end
local S2 = tonumber(frame:expandTemplate{title='Template parameter value',args={S2,T2,1,T3,1}})
if(S2 == nil) then S2 = 0 end
local S3 = tonumber(frame:expandTemplate{title='Template parameter value',args={S3,T2,1,T3,1}})
if(S3 == nil) then S3 = 0 end
local S4 = tonumber(frame:expandTemplate{title='Template parameter value',args={S4,T2,1,T3,1}})
if(S4 == nil) then S4 = 0 end
local S5 = tonumber(frame:expandTemplate{title='Template parameter value',args={S5,T2,1,T3,1}})
if(S5 == nil) then S5 = 0 end
local S6 = tonumber(frame:expandTemplate{title='Template parameter value',args={S6,T2,1,T3,1}})
if(S6 == nil) then S6 = 0 end
local S7 = tonumber(frame:expandTemplate{title='Template parameter value',args={S7,T2,1,T3,1}})
if(S7 == nil) then S7 = 0 end
local S8 = tonumber(frame:expandTemplate{title='Template parameter value',args={S8,T2,1,T3,1}})
if(S8 == nil) then S8 = 0 end
local S9 = tonumber(frame:expandTemplate{title='Template parameter value',args={S9,T2,1,T3,1}})
if(S9 == nil) then S9 = 0 end
local S10 = tonumber(frame:expandTemplate{title='Template parameter value',args={S10,T2,1,T3,1}})
if(S10 == nil) then S10 = 0 end
if(year == nil) then year = "year" end
if(month == nil) then month = "month" end
if(day == nil) then day = "day" end
if(Date == nil) then Date = month .. " " .. day .. ", " .. year end
if(sum == nil) then sum = (mw.getContentLanguage():formatNum(S1+S2+S3+S4+S5+S6+S7+S8+S9+S10)) end
return "As of " .. Date .. ", " .. sum .. " episodes of the ''" .. name .. "'' franchise have aired."
end
return p