Module:Infobox Skill

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

-- Build an Infobox_Skill function skillBox( args, skillData) -- check that all necessary arguments are passed correctly if args.name == nil or args.name == '' then return '\'name\' must be specified.' end local skill = args.name

local skillimagename = string.gsub(skill, ' ', '') local skillTable = skillData.skills[skill] if skillTable == nil then if item ~= nil then return item .. ' could not be found in Module:Skills.' end end -- string used to build the infobox local infobox = '{| class=\"infobox\"\n' -- name of the skill infobox = infobox .. '|- style=\"background-color: darkred; text-align: center;\"\n| colspan=\"2\" | \'\'\' ' .. skill .. ' \'\'\'\n' -- Prof,Spec,Skill box infobox = infobox .. '|- style=\"text-align: center; background-color: #af8d33;\"\n| colspan=\"2\"' if skillTable ~= nil then if skillTable.root == true then infobox = infobox .. '| \'\'\'Profession\'\'\'\n' elseif skillTable.specialty == true then infobox = infobox .. '| \'\'\'Specialty\'\'\'\n' else infobox = infobox .. '| \'\'\'Skill\'\'\'\n' end end -- Skill Icon Image local image = 'NoImage.png|link=https://eco.gamepedia.com/index.php?title=Special:Upload&wpDestFile=' .. skillimagename .. '_Icon.png|' if mw.title.makeTitle('File', skillimagename .. '_Icon.png').exists then image = skillimagename .. '_Icon.png' elseif mw.title.makeTitle('File', skillimagename .. '_Icon.jpg').exists then image = skillimagename .. '_Icon.jpg' end infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | \n' -- 'Description' section header infobox = infobox .. '|- style=\"background-color: #4B9130; text-align: center;\"\n| colspan=\"2\" | \'\'\'Description\'\'\'\n' if skillTable.description == nil then infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n' elseif skillTable.description == '' then infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n' else infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. skillTable.description .. '\n' end

-- 'Related Skills' section header infobox = infobox .. '|- style=\"background-color: #4B9130; text-align: center;\"\n| colspan=\"2\" | \'\'\'Related Skills\'\'\'\n' -- Professsion .rootSkill if skillTable.rootSkill ~= nil then infobox = infobox .. '|-\n| Profession:\n| style=\"text-align: right;\" | ' .. skillTable.rootSkill .. '\n' end -- Specialty    .specialitySkill if skillTable.specialitySkill ~= nil then infobox = infobox .. '|-\n| Specialty:\n| style=\"text-align: right;\" | ' .. skillTable.specialitySkill .. '\n' end -- Skills Required .prerequisites if skillTable.prerequisites ~= nil then infobox = infobox .. '|-\n| Skills Required:\n| style=\"text-align: right;\" | ' .. skillTable.prerequisites .. '\n' end -- Leads to childSkills if skillTable.childSkills ~= nil then infobox = infobox .. '|-\n| Leads to:\n| style=\"text-align: right;\" | ' .. skillTable.childSkills .. '\n' end

-- 'Skill Information' section header infobox = infobox .. '|- style=\"background-color: #4B9130; text-align: center;\"\n| colspan=\"2\" | \'\'\'Skill Information\'\'\'\n' -- maxlevel .maxLevel if skillTable.maxLevel ~= nil then infobox = infobox .. '|-\n| Max Level:\n| style=\"text-align: right;\" | Level ' .. skillTable.maxLevel .. '\n' end -- items given .itemsGiven if skillTable.itemsGiven ~= nil then infobox = infobox .. '|-\n| Items Given:\n| style=\"text-align: right;\" | ' .. skillTable.itemsGiven .. '\n' end -- 'IDs' section header infobox = infobox .. '|- style=\"background-color: #4B9130; text-align: center;\"\n| colspan=\"2\" | \'\'\'IDs\'\'\'\n' -- skill id (type) infobox = infobox .. '|- valign=\"center\"\n| Item ID:\n| style=\"text-align: right;\" | ' .. skillTable.skillID .. '\n' -- id number (type id) infobox = infobox .. '|- valign=\"center\"\n| ID Number:\n| style=\"text-align: right;\" | ' .. skillTable.skillIDNum .. '\n' infobox = infobox .. '|}'   return infobox end

-- Main entry point for the Module function p.SkillMain -- get args from the Template local args = norm -- get skill data local skillData = require( "Module:Skills" ) return skillBox( args, skillData) end

return p