Module:Infobox Skill: Difference between revisions

From Eco - English Wiki
[unchecked revision][unchecked revision]
No edit summary
No edit summary
 
(58 intermediate revisions by 3 users not shown)
Line 1: Line 1:
local p = {}
local p = {}
local Utils = require('Module:Utils')


-- Grabs args from the parent frame
-- Grabs args from the parent frame
Line 17: Line 18:
end
end


-- Main entry point for the Module
function p.SkillMain()
    -- get args from the Template
    local args = norm()
   
-- create values outside of if statements to ensure they are available to whole function
local skills = ''
    skills = args.skill
     
-- check to see if skills was actually passed in
if skills == '' then
return 'skill must be specified.'
    end
 
local skillData = {}
local skillTable = {}
 
    skillData = require( "Module:SkillData" )
    skillTable = skillData.skills[skills]
    -- checks if skills can be found in plant data or tree data based on what was requested
    if skillTable == {} then
            return skills .. ' could not be found in Module:Skills.'
    end


-- Build an Infobox_Skill
     -- From now on using skillsTable."KeyValue" will return the value from that key. for most things a check for skills type is not necessary
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, ' ', '')
-- Build an Infobox_Plant
-- string used to build the infobox
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'
     local infobox = '{| class=\"infobox\"\n'
   
 
     -- name of the skill
     -- name of the skill/talent
    infobox = infobox .. '|- style=\"background-color: darkred; text-align: center;\"\n| colspan=\"2\" | \'\'\'<big>' .. skill .. '</big>\'\'\'\n'
  infobox = infobox .. '|- style=\"color: white; background-color: #1165AF; text-align: center;\"\n| colspan=\"2\" | \'\'\'<big>' .. skills .. '</big>\'\'\'\n'
     
    -- Prof,Spec,Skill box
      infobox = infobox .. '|- style=\"text-align: center;color: white; background-color: goldenrod;\"\n| colspan=\"2\"'
    infobox = infobox .. '|- style=\"text-align: center; background-color: #af8d33;\"\n| colspan=\"2\"'
     if skillTable.Root == 'True' then
     if skillTable ~= nil then
        infobox = infobox .. '| \'\'\'Profession\'\'\'[[Category:Profession]]\n'
        if skillTable.root == true then
    elseif skillTable.Root == 'False' then
            infobox = infobox .. '| \'\'\'Profession\'\'\'\n'
        infobox = infobox .. '| \'\'\'Specialty\'\'\'[[Category:Specialty]]\n'
        elseif skillTable.specialty == true then
else
            infobox = infobox .. '| \'\'\'Specialty\'\'\'\n'
        infobox = infobox .. '|\n'
        else  
            infobox = infobox .. '| \'\'\'Skill\'\'\'\n'    
        end
     end
     end
 
-- Skill
local SkillIcon = Utils.checkImage(skillTable.SkillID)
    infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | [[File:' .. SkillIcon .. '|center|link=]] \n'
-- 'Description' section header
    infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Description\'\'\'\n'
        -- Skill Icon Image
if skillTable.Description == nil then
    local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. skillimagename .. '_Icon.png|[[Category:Pages_with_missing_skill_icon]]'
    if mw.title.makeTitle('File', skillimagename .. '_Icon.png').file.exists then
        image = skillimagename .. '_Icon.png'
    elseif mw.title.makeTitle('File', skillimagename .. '_Icon.jpg').file.exists then
        image = skillimagename .. '_Icon.jpg'
    end
   
infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | [[File:' .. image .. '|center|frameless|95px]]\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'
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n'
elseif skillTable.description == '' then
elseif skillTable.Description == '' then
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n'
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n'
else
else
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. skillTable.description .. '\n'
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. skillTable.Description .. '\n'
end
end


--SKILL
  -- '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
  -- 'Skill Information' section header
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Skill Information\'\'\'\n'
    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'
-- Professsion
if skillTable.Root == 'False' then
infobox = infobox .. '|-\n| Profession:\n| style=\"text-align: right; padding: 3px;\" | [[' .. skillTable.RootSkill .. ']]\n'
end
 
-- maxlevel .maxLevel
if skillTable.MaxLevel ~= nil then
infobox = infobox .. '|-\n| Max Level:\n| style=\"text-align: right; padding: 3px;\" | Level ' .. skillTable.MaxLevel .. '\n'
end
-- skill id (type)
infobox = infobox .. '|- valign=\"center\"\n| Skill ID:\n| style=\"text-align: right; padding: 3px;\" | ' .. skillTable.SkillID.. '\n'
     infobox = infobox .. '|}'
     infobox = infobox .. '|}'
     return 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
end


return p
return p

Latest revision as of 05:54, 18 November 2024

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

If the template is passed an Infobox will be made using details from the following Modules:

Credit[edit source]

Original Infobox (now known as Infobox_Item) created by Pradoxzon was then edited by Nesphit and TreeNuts0. Fyre (FishAus) and Scotty (ZeelNightwolf) further edited the Infobox_Item. They then duplicated and used as a base for Infobox_Skill, Infobox_Plant, and Infobox_Animal.


local p = {}
local Utils = require('Module:Utils')

-- 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.SkillMain()
     -- get args from the Template
    local args = norm()
    
	-- create values outside of if statements to ensure they are available to whole function
	local skills = ''
    skills = args.skill
      
	-- check to see if skills was actually passed in
	if skills == '' then
		return 'skill must be specified.'
    end
   
	local skillData = {}
	local skillTable = {}
   
    skillData = require( "Module:SkillData" )
    skillTable = skillData.skills[skills]
 
    -- checks if skills can be found in plant data or tree data based on what was requested
    if skillTable == {} then
            return skills .. ' could not be found in Module:Skills.'
    end

    -- From now on using skillsTable."KeyValue" will return the value from that key. for most things a check for skills type is not necessary

-- Build an Infobox_Plant
	-- string used to build the infobox
    local infobox = '{| class=\"infobox\"\n'
   
    -- name of the skill/talent
   infobox = infobox .. '|- style=\"color: white; background-color: #1165AF; text-align: center;\"\n| colspan=\"2\" | \'\'\'<big>' .. skills .. '</big>\'\'\'\n'
 
       infobox = infobox .. '|- style=\"text-align: center;color: white; background-color: goldenrod;\"\n| colspan=\"2\"'
    if skillTable.Root == 'True' then
        infobox = infobox .. '| \'\'\'Profession\'\'\'[[Category:Profession]]\n'
    elseif skillTable.Root == 'False' then
        infobox = infobox .. '| \'\'\'Specialty\'\'\'[[Category:Specialty]]\n'
	else
        infobox = infobox .. '|\n'	
    end
   
	-- Skill
	local SkillIcon = Utils.checkImage(skillTable.SkillID) 
    infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | [[File:' .. SkillIcon .. '|center|link=]] \n'

	-- 'Description' section header
    infobox = infobox .. '|- style=\"background-color: #4688C0; 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

	--SKILL

	  -- 'Skill Information' section header
		infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Skill Information\'\'\'\n'
		
		-- Professsion 
		if skillTable.Root == 'False' then
			infobox = infobox .. '|-\n| Profession:\n| style=\"text-align: right; padding: 3px;\" | [[' .. skillTable.RootSkill .. ']]\n'
		end

		-- maxlevel .maxLevel
		if skillTable.MaxLevel ~= nil then
			infobox = infobox .. '|-\n| Max Level:\n| style=\"text-align: right; padding: 3px;\" | Level ' .. skillTable.MaxLevel .. '\n'
		end	
			
		-- skill id (type)
		infobox = infobox .. '|- valign=\"center\"\n| Skill ID:\n| style=\"text-align: right; padding: 3px;\" | ' .. skillTable.SkillID.. '\n'
	
    infobox = infobox .. '|}'
    return infobox
end

return p