Module:TagsList: Difference between revisions

From Eco - English Wiki
[checked revision][checked revision]
No edit summary
No edit summary
Line 41: Line 41:
local a = {}
local a = {}
--Talent List
--Tags List
if list == 'tags' then
if list == 'tags' then
tagsList = tagsList .. '=== Tags List ===\n'
tagsList = tagsList .. '=== Tags List ===\n'    
tagsList = tagsList .. '<div style=\"column-count:2;-moz-column-count:2;-webkit-column-count:2\">\n'
   
for k,v in pairs(itemData.tags) do         
for k,v in pairs(itemData.tags) do         
             if itemData.tags ~= nil then
             if itemData.tags[k] ~= nil 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
             tagsList = tagsList .. '* [[' .. k .. ']]\n'                 
             tagsList = tagsList .. '* [[' .. n .. ']]\n'                 
         end
         end
end
tagsList = tagsList .. '</div>'
end
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
return tagsList
return tagsList
end
end


return p
return p

Revision as of 09:19, 21 February 2021

Documentation

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

If the template is passed, this module creates a list using details from the following Modules:

Credit

Original SkillList was created by Fyre (FishAus) then edited by Scotty (ZeelNightwolf) and used as a base for TagsList.


-- Credit: Original SkillList was created by Fyre (FishAus) then edited by Scotty (ZeelNightwolf) and used as a base for tagsList.

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 itemData = require( "Module:ItemData" )
	local tagsList = ''

	--Check Passes
	if list ~= 'tags' then
        return tagsList .. ' Incorrect use of pass. '
    end	
	
	local a = {}
	--Tags List
	if list == 'tags' then
		tagsList = tagsList .. '=== Tags List ===\n'      	
																																						 
	 
		for k,v in pairs(itemData.tags) do        
            if itemData.tags[k] ~= nil then
               table.insert(a,k)
            end
        end
        table.sort(a)
        for i,n in ipairs(a) do
            tagsList = tagsList .. '* [[' .. n .. ']]\n'                
        end
	end
	
return tagsList
end

return p