Module:SongContestData
Appearance
![]() | This module is rated as pre-alpha. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure. |
![]() | This module depends on the following other modules: |
Usage
The module looks for data in Module:SongContestData/
{{{1}}}
/{{{2}}}
main
Returns an attribute value from an entry
{{#invoke:SongContestData|main}}
- Required parameters
Parameter | Description |
---|---|
|1=
|
Contest |
|2=
|
Year |
|3=
|
Entry |
|4=
|
Attribute |
- Examples
{{#invoke:SongContestData|main|esc|2019|no|artist}}
Keiino{{#invoke:SongContestData|main|esc|2019|no|title}}
Spirit in the Sky{{#invoke:SongContestData|main|esc|2019|no|gf_pt}}
331
entryAmount
Returns the amount of entries in a given contest year
{{#invoke:SongContestData|entryAmount}}
- Required parameters
Parameter | Description |
---|---|
|1=
|
Contest |
|2=
|
Year |
- Examples
{{#invoke:SongContestData|entryAmount|esc|2019}}
Script error: The function "entryAmount" does not exist.
order
- Required parameters
Parameter | Description |
---|---|
|1=
|
Contest |
|2=
|
Year |
|3=
|
Attribute to sort |
- Optional parameters
Parameter | Description | Default |
---|---|---|
|desc=
|
Sorts descending if set, otherwise sorts ascending | |
|excludeAtt='String'
|
Excludes entries with set attribute | |
|excludeVal=value
|
Excludes entries where the value of the |excludeAtt= attribute is equal to this parameter
|
|
|excludeInvert=true/false
|
Inverts exclusion. Excludes entries where the value of the |excludeAtt= attribute is not equal to |excludeVal=
|
false |
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