Jump to content

Module:SongContestData

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by TheThomanski (talk | contribs) at 21:16, 9 March 2025. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local getArgs = require('Module:Arguments').getArgs
local p = {}

local function tableToString(t)
    local result = {}
    for _, v in pairs(t) do
        table.insert(result, tostring(v))
    end
    return table.concat(result, ";")
end

function p.main(f)
	local args = getArgs(f)
	
	local contest   = args[1]
	local year      = args[2]
	local entry     = args[3]
	local attribute = args[4]
	
	local contest = mw.loadData('Module:SongContestData/'..contest..'/'..year)

    local result = ""
	for k, v in pairs(contest[entry]) do
		if (k == attribute) then
			if type(v) == "table" then
				result = tableToString(v)
				break
			end
			result = v
			break
		end
	end
	return result
end

return p