Module:TalentList: Difference between revisions
From Eco - English Wiki
[unchecked revision] | [checked revision] |
Test |
Undo revision 5116 by ZeelNightwolf (talk) Tag: Undo |
||
Line 1: | Line 1: | ||
-- Credit: Original SkillList was created by Fyre (FishAus) then edited by Scotty (ZeelNightwolf) and used as a base for | -- Credit: Original SkillList was created by Fyre (FishAus) then edited by Scotty (ZeelNightwolf) and used as a base for TalentList. | ||
local p = {} | local p = {} | ||
Line 32: | Line 32: | ||
-- load lists | -- load lists | ||
local | local talentData = require( "Module:TalentData" ) | ||
local | local talentList = '' | ||
--Check Passes | --Check Passes | ||
if list ~= ' | if list ~= 'talents' then | ||
return | return talentList .. ' Incorrect use of pass. ' | ||
end | end | ||
local a = {} | local a = {} | ||
--Talent List | --Talent List | ||
if list == ' | if list == 'talents' then | ||
talentList = talentList .. '=== Talents List ===\n' | |||
talentList = talentList .. '<div style=\"column-count:3;-moz-column-count:3;-webkit-column-count:3\">\n' | |||
for k,v in pairs( | for k,v in pairs(talentData.talents) do | ||
if | if talentData.talents[k].group == 'Talents' then | ||
table.insert(a,k) | table.insert(a,k) | ||
end | end | ||
Line 53: | Line 53: | ||
table.sort(a) | table.sort(a) | ||
for i,n in ipairs(a) do | for i,n in ipairs(a) do | ||
talentList = talentList .. '* [[' .. n .. ']]\n' | |||
end | end | ||
talentList = talentList .. '</div>' | |||
end | end | ||
return | return talentList | ||
end | end | ||
return p | return p |
Latest revision as of 17:22, 20 February 2021
Documentation[edit source]
This module provides the back end functionality of the Template:TalentList.
If the template is passed, this module creates a list using details from the following Modules:
Credit[edit source]
Original SkillList was created by Fyre (FishAus) then edited by Scotty (ZeelNightwolf) and used as a base for TalentList.
-- Credit: Original SkillList was created by Fyre (FishAus) then edited by Scotty (ZeelNightwolf) and used as a base for TalentList.
local p = {}
-- Grabs args from the parent frame
-- Trims and parses the args into a table, then returns the table
function norm()
local origArgs = mw.getCurrentFrame():getParent().args
local args = {}
for k, v in pairs( origArgs ) do
v = mw.text.trim( tostring( v ) )
if v ~= '' then
args[k] = v
end
end
return args
end
-- Main entry point for the Module
function p.main()
-- get args from the Template
local args = norm()
if args.list == nil or args.list == '' then
return '\'list\' must be specified.'
end
-- assign variables for list
local list = args.list
-- load lists
local talentData = require( "Module:TalentData" )
local talentList = ''
--Check Passes
if list ~= 'talents' then
return talentList .. ' Incorrect use of pass. '
end
local a = {}
--Talent List
if list == 'talents' then
talentList = talentList .. '=== Talents List ===\n'
talentList = talentList .. '<div style=\"column-count:3;-moz-column-count:3;-webkit-column-count:3\">\n'
for k,v in pairs(talentData.talents) do
if talentData.talents[k].group == 'Talents' then
table.insert(a,k)
end
end
table.sort(a)
for i,n in ipairs(a) do
talentList = talentList .. '* [[' .. n .. ']]\n'
end
talentList = talentList .. '</div>'
end
return talentList
end
return p