Module:SkillList: Difference between revisions

From Eco - English Wiki
[unchecked revision][unchecked revision]
Adding Credit
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
-- 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 30:
     -- load lists
     -- load lists
     local skillData = require( "Module:TestSkills" )
     local skillData = require( "Module:SkillData" )
local skillList = ''
local skillList = ''


Line 45: Line 43:
skillList = skillList .. '=== Profession List ===\n'     
skillList = skillList .. '=== Profession List ===\n'     
for k,v in pairs(skillData.skills) do         
for k,v in pairs(skillData.skills) do         
             if skillData.skills[k].root == true then
             if skillData.skills[k].Root == 'True' then
               table.insert(a,k)
               table.insert(a,k)
             end
             end
Line 61: Line 59:
for k,v in pairs(skillData.skills) do         
for k,v in pairs(skillData.skills) do         
if skillData.skills[k].specialty == true and skillData.skills[k].root == false then
if skillData.skills[k].Root == 'False' then
               table.insert(a,k)
               table.insert(a,k)
             end
             end
Line 72: Line 70:
skillList = skillList .. '</div>'
skillList = skillList .. '</div>'
end
end
-- --Skill List (exclude Profession and Specialty)
-- if list == 'skill' then
-- skillList = skillList .. '=== Skill List ===\n'
-- skillList = skillList .. '<div style=\"column-count:3;-moz-column-count:3;-webkit-column-count:3\">\n'
-- for k,v in pairs(skillData.skills) do       
-- if skillData.skills[k].specialty == false and skillData.skills[k].root == false then
              -- table.insert(a,k)
            -- end
        -- end
        -- table.sort(a)
        -- for i,n in ipairs(a) do
            -- skillList = skillList .. '* [[' .. n .. ']]\n'               
        -- end
-- skillList = skillList .. '</div>'
-- end
return skillList
return skillList

Latest revision as of 16:07, 17 November 2024

This module provides the back end functionality of the Template:SkillList.

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.


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 skillData = require( "Module:SkillData" )
	local skillList = ''

	--Check Passes
	if list ~= 'profession' and list ~= 'specialty' and list ~= 'skill' then
        return skillList .. ' Incorrect use of pass. '
    end	
	
	local a = {}
	--Profession List
	if list == 'profession' then
		skillList = skillList .. '=== Profession List ===\n'      	
		for k,v in pairs(skillData.skills) do        
            if skillData.skills[k].Root == 'True' then
               table.insert(a,k)
            end
        end
        table.sort(a)
        for i,n in ipairs(a) do
            skillList = skillList .. '* [[' .. n .. ']]\n'                
        end
	end
		
	--Specialty List
	if list == 'specialty' then
	skillList = skillList .. '=== Specialty List ===\n'
	skillList = skillList .. '<div style=\"column-count:2;-moz-column-count:2;-webkit-column-count:2\">\n'
		
		for k,v in pairs(skillData.skills) do        
			if skillData.skills[k].Root == 'False' then
               table.insert(a,k)
            end
        end
        table.sort(a)
        for i,n in ipairs(a) do
            skillList = skillList .. '* [[' .. n .. ']]\n'                
        end		
		
	skillList = skillList .. '</div>'
	end	
	
return skillList
end

return p