My Little Pony Friendship is Magic Wiki
mNo edit summary
(pass through vars from template call)
Line 1: Line 1:
--Please see [[Template:Eps]] for documentation.
+
--Please see [[Template:Eps]] for documentation. Do not use #invoke directly.
 
local p = {}
 
local p = {}
   
 
function p.main(frame)
 
function p.main(frame)
return p.call(frame.args)
+
return p.call(frame:getParent().args)
 
end
 
end
   

Revision as of 15:22, 30 May 2020

Documentation for this module may be created at Module:Eps/doc

--Please see [[Template:Eps]] for documentation. Do not use #invoke directly.
local p = {}

function p.main(frame)
    return p.call(frame:getParent().args)
end

function p.call(args)
    local result
    local gs = tonumber(args.gs)
    if gs then
        if 0 < gs and gs < 27 then
            result = 1
        elseif 26 < gs and gs < 53 then
            result = 2
        elseif 52 < gs and gs < 66 then
            result = 3
        elseif 65 < gs and gs < 92 then
            result = 4
        elseif 91 < gs and gs < 118 then
            result = 5
        elseif 117 < gs and gs < 144 then
            result = 6
        elseif 143 < gs and gs < 170 then
            result = 7
        elseif 169 < gs and gs < 197 then
            result = 8
        elseif 196 < gs and gs < 229 then
            result = 9
        end
        
        if not result then
            result = '<span class="error">Invalid episode number</span>'
        elseif args[1] then
           local spell = {'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'}
           result = spell[result]
        end
    else
        local arg = tonumber(args[1])
        local count = {}
        if args[2] then
            count = {26, 52, 65, 91, 117, 143, 169, 196, 228}
        else
            count = {26, 26, 13, 26, 26, 26, 26, 27, 32}
        end
        if count[arg] then
            result = count[arg]
        else
            result = 0
        end
    end
    
    return tostring(result)
end
    
return p