Module:Event

local p = {} data = mw.loadData("Module:Event/Data")

local function getArgs(frame) local args = {} for key, value in pairs(frame:getParent.args) do       args[key] = value end for key, value in pairs(frame.args) do       args[key] = value end return args end

function p.main(frame) local args      = getArgs(frame) local game      = args[1] or args.game or '' local eventname = args[2] or args.eventname or '' local year      = args[3] or args.year or '' local startEvent = args[4] or args.startEvent or '' local endEvent  = args[5] or args.endEvent or '' return p.outputEvent(game, eventname, year, startEvent, endEvent) end

function p.outputEvent(game, eventname, year, startEvent, endEvent) local function isEmpty(s) return s == nil or s == '' end local function tableEmpty(s) return next(s) == nil end local print = '' if not isEmpty(eventname) and not isEmpty(game) then if not isEmpty(year) then data2 = mw.loadData(data.year[game]) if not isEmpty(startEvent) then print = print .. data2[year][eventname][1] elseif not isEmpty(endEvent) then print = print .. data2[year][eventname][2] else print = print .. data2[year][eventname][1] end else if not isEmpty(startEvent) then print = print .. data.reoccuring[game][eventname][1] elseif not isEmpty(endEvent) then print = print .. data.reoccuring[game][eventname][2] else print = print .. data.reoccuring[game][eventname][1] end end end return print end

return p