Module:Item timeline by year

From Team Fortress Wiki
Revision as of 19:30, 21 March 2024 by Tark (talk | contribs) (test)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Usage

  • {{#invoke:Item timeline by year|list}} produces:
  • {{#invoke:Item timeline by year|list|12}} produces:
  • {{#invoke:Item timeline by year|list|1}} produces:
  • {{#invoke:Item timeline by year|list|9999}} produces:

local p = {}

function p.generate(f)
    local output = {}
    local startYear = 2007
    local currentYear = tonumber(os.date("%Y"))
    local split = f.args[1] or 6
    local if_lang = f:expandTemplate{title='If lang'}
    
    for year = startYear, currentYear, split do
        table.insert(output, '<div style="display:inline-table">')

        for y = year, math.min(year + split - 1, currentYear) do
            table.insert(output, string.format(':*  [[Item timeline in %d%s|%d]]', y, if_lang, y))
        end

        table.insert(output, '</div>')
    end

    return table.concat(output, "\n")
end

return p