Module:SkillDetails: Difference between revisions

From Eco - English Wiki
[unchecked revision][unchecked revision]
No edit summary
No edit summary
Line 17: Line 17:
      
      
     return args
     return args
end
function p.benefits( benTable )
local builder = '<div style=\"column-count:2;-moz-column-count:2;-webkit-column-count:2\"><small>'
for i,v in pairs(benTable) do
builder = builder .. i[1] .. ': ' .. i[2] .. ' the ' .. i[3] .. ' by ' .. i[4].. '. <br />'
end
end
end


Line 114: Line 107:
wikibox = wikibox .. '| '
wikibox = wikibox .. '| '
if skillTable.benefits.level0 ~= nil then
if skillTable.benefits.level0 ~= nil then
wikibox = wikibox .. p.benefits( skillTable.benefits.level0 )
wikibox = wikibox .. skillTable.benefits.level0[1] .. ': ' .. skillTable.benefits.level0[2] .. ' the ' .. skillTable.benefits.level0[3] .. ' by ' .. skillTable.benefits.level0[4]
end
end
wikibox = wikibox .. '\n'
wikibox = wikibox .. '\n'
Line 153: Line 146:
wikibox = wikibox .. '| '
wikibox = wikibox .. '| '
if skillTable.benefits.level1 ~= nil then
if skillTable.benefits.level1 ~= nil then
wikibox = wikibox .. p.benefits( skillTable.benefits.level1 )
wikibox = wikibox .. skillTable.benefits.level1[1] .. ': ' .. skillTable.benefits.level1[2] .. ' the ' .. skillTable.benefits.level1[3] .. ' by ' .. skillTable.benefits.level1[4]
end
end
wikibox = wikibox .. '\n'
wikibox = wikibox .. '\n'
Line 192: Line 185:
wikibox = wikibox .. '| '
wikibox = wikibox .. '| '
if skillTable.benefits.level2 ~= nil then
if skillTable.benefits.level2 ~= nil then
wikibox = wikibox .. p.benefits( skillTable.benefits.level2 )
wikibox = wikibox .. skillTable.benefits.level2[1] .. ': ' .. skillTable.benefits.level2[2] .. ' the ' .. skillTable.benefits.level2[3] .. ' by ' .. skillTable.benefits.level2[4]
end
end
wikibox = wikibox .. '\n'
wikibox = wikibox .. '\n'
Line 231: Line 224:
wikibox = wikibox .. '| '
wikibox = wikibox .. '| '
if skillTable.benefits.level3 ~= nil then
if skillTable.benefits.level3 ~= nil then
wikibox = wikibox .. p.benefits( skillTable.benefits.level3 )
wikibox = wikibox .. skillTable.benefits.level3[1] .. ': ' .. skillTable.benefits.level3[2] .. ' the ' .. skillTable.benefits.level3[3] .. ' by ' .. skillTable.benefits.level3[4]
end
end
wikibox = wikibox .. '\n'
wikibox = wikibox .. '\n'
Line 270: Line 263:
wikibox = wikibox .. '| '
wikibox = wikibox .. '| '
if skillTable.benefits.level4 ~= nil then
if skillTable.benefits.level4 ~= nil then
wikibox = wikibox .. p.benefits( skillTable.benefits.level4 )
wikibox = wikibox .. skillTable.benefits.level4[1] .. ': ' .. skillTable.benefits.level4[2] .. ' the ' .. skillTable.benefits.level4[3] .. ' by ' .. skillTable.benefits.level4[4]
end
end
wikibox = wikibox .. '\n'
wikibox = wikibox .. '\n'
Line 309: Line 302:
wikibox = wikibox .. '| '
wikibox = wikibox .. '| '
if skillTable.benefits.level5 ~= nil then
if skillTable.benefits.level5 ~= nil then
wikibox = wikibox .. p.benefits( skillTable.benefits.level5 )
wikibox = wikibox .. skillTable.benefits.level5[1] .. ': ' .. skillTable.benefits.level5[2] .. ' the ' .. skillTable.benefits.level5[3] .. ' by ' .. skillTable.benefits.level5[4]
end
end
wikibox = wikibox .. '\n'
wikibox = wikibox .. '\n'
Line 348: Line 341:
wikibox = wikibox .. '| '
wikibox = wikibox .. '| '
if skillTable.benefits.level6 ~= nil then
if skillTable.benefits.level6 ~= nil then
wikibox = wikibox .. p.benefits( skillTable.benefits.level6 )
wikibox = wikibox .. skillTable.benefits.level6[1] .. ': ' .. skillTable.benefits.level6[2] .. ' the ' .. skillTable.benefits.level6[3] .. ' by ' .. skillTable.benefits.level6[4]
end
end
wikibox = wikibox .. '\n'
wikibox = wikibox .. '\n'
Line 387: Line 380:
wikibox = wikibox .. '| '
wikibox = wikibox .. '| '
if skillTable.benefits.level7 ~= nil then
if skillTable.benefits.level7 ~= nil then
wikibox = wikibox .. p.benefits( skillTable.benefits.level7 )
wikibox = wikibox .. skillTable.benefits.level7[1] .. ': ' .. skillTable.benefits.level7[2] .. ' the ' .. skillTable.benefits.level7[3] .. ' by ' .. skillTable.benefits.level7[4]
end
end
wikibox = wikibox .. '\n'
wikibox = wikibox .. '\n'

Revision as of 06:46, 28 August 2020

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

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

Credit

Original SkillDetails was created by Fyre (FishAus) then edited by Scotty (ZeelNightwolf).


-- Credit: Original SkillDetails was created by Fyre (FishAus) then edited by Scotty (ZeelNightwolf).

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.skill == nil or args.skill == '' then
        return '\'skill\' must be specified.'
    end
	
    -- assign variables for plant
    local skill = args.skill
	
    -- load list of recipes
    local skillData = require( "Module:TestSkills" )
    local skillTable = skillData.skills[skill]
    if skillTable == nil then
		return skill .. ' could not be found in Module:Skills.'
	end    

	local wikibox = ''
	-- Profession Skill 
	if skillTable.root == true then
		wikibox = wikibox .. '==' .. skill .. ' Unlocks==\n'
		wikibox = wikibox .. '{| class=\"wikitable\"  \n'
		wikibox = wikibox .. '! style="width: 5em; text-align: center;" |Level \n'
		wikibox = wikibox .. '! style="width: 10em;" |Skill Unlocks \n'
		wikibox = wikibox .. '|- \n'
		wikibox = wikibox .. '| 0 \n'
		wikibox = wikibox .. '| '
		if skillTable.childSkills ~= nil then
			for i,v in pairs(skillTable.childSkills) do
				wikibox = wikibox .. skillTable.childSkills[i] .. '<br />'
			end
		end
		wikibox = wikibox .. '\n'
		wikibox = wikibox .. '|}\n\n'
	end	
		
	-- Specialty
	if skillTable.root ~= true and skillTable.specialty == true then
		local anyBenefits = skillTable.benefits.level1 ~= nil or skillTable.benefits.level2 ~= nil or skillTable.benefits.level3 ~= nil or skillTable.benefits.level4 ~= nil or skillTable.benefits.level5 ~= nil or skillTable.benefits.level6 ~= nil or skillTable.benefits.level7 ~=nil
		
		local anyTalents = skillTable.talents.level0 ~= nil or skillTable.talents.level1 ~= nil or skillTable.talents.level2 ~= nil or skillTable.talents.level3 ~= nil or skillTable.talents.level4 ~= nil or skillTable.talents.level5 ~= nil or skillTable.talents.level6 ~= nil or skillTable.talents.level7 ~= nil
		
		--Headings
		wikibox = wikibox .. '==' .. skill .. ' Unlocks==\n'
		wikibox = wikibox .. '{| class=\"wikitable\" \n'
		wikibox = wikibox .. '! Level \n'
		wikibox = wikibox .. '! Crafting Unlocks \n'
		wikibox = wikibox .. '! Talent Unlocks \n'		
		if anyBenefits then 
			wikibox = wikibox .. '! Benefits \n'
		end	
		
		--Level 0
		wikibox = wikibox .. '|- \n'
		wikibox = wikibox .. '| 0\n'
		wikibox = wikibox .. '| '
		--Crafting 0
		if skillTable.recipes.level0 ~= nil then
			wikibox = wikibox .. '| '		
			if skillTable.recipes.level0 ~= nil then
				for i,v in pairs(skillTable.recipes.level0) do
					wikibox = wikibox .. skillTable.recipes.level0[i] .. '<br />'
				end	
			wikibox = wikibox .. '\n'
			end
		else
			wikibox = wikibox .. '\n'
		end
		--Talent 0
		if anyTalents then
			wikibox = wikibox .. '| '
			if skillTable.talents.level0 ~= nil then	
				if skillTable.talents.level0 ~= nil then
					for i,v in pairs(skillTable.talents.level0) do
						wikibox = wikibox .. skillTable.talents.level0[i] .. '<br />'
					end	
				wikibox = wikibox .. '\n'
				end
			else
				wikibox = wikibox .. '\n'
			end	
		end
		--Benefits 0
		if anyBenefits then
			wikibox = wikibox .. '| '
			if skillTable.benefits.level0 ~= nil then
				wikibox = wikibox .. skillTable.benefits.level0[1] .. ': ' .. skillTable.benefits.level0[2] .. ' the ' .. skillTable.benefits.level0[3] .. ' by ' .. skillTable.benefits.level0[4]
			end
			wikibox = wikibox .. '\n'
		end
		
		--Level 1
		wikibox = wikibox .. '|- \n'
		wikibox = wikibox .. '| 1\n'
		wikibox = wikibox .. '| '
		--Crafting 1
		if skillTable.recipes.level1 ~= nil then
			wikibox = wikibox .. '| '		
			if skillTable.recipes.level1 ~= nil then
				for i,v in pairs(skillTable.recipes.level1) do
					wikibox = wikibox .. skillTable.recipes.level1[i] .. '<br />'
				end	
			wikibox = wikibox .. '\n'
			end
		else
			wikibox = wikibox .. '\n'
		end
		--Talent 1
		if anyTalents then
			wikibox = wikibox .. '| '
			if skillTable.talents.level1 ~= nil then	
				if skillTable.talents.level1 ~= nil then
					for i,v in pairs(skillTable.talents.level1) do
						wikibox = wikibox .. skillTable.talents.level1[i] .. '<br />'
					end	
				wikibox = wikibox .. '\n'
				end
			else
				wikibox = wikibox .. '\n'
			end	
		end
		--Benefits 1
		if anyBenefits then
			wikibox = wikibox .. '| '
			if skillTable.benefits.level1 ~= nil then
				wikibox = wikibox .. skillTable.benefits.level1[1] .. ': ' .. skillTable.benefits.level1[2] .. ' the ' .. skillTable.benefits.level1[3] .. ' by ' .. skillTable.benefits.level1[4]
			end
			wikibox = wikibox .. '\n'
		end

		--Level 2
		wikibox = wikibox .. '|- \n'
		wikibox = wikibox .. '| 2\n'
		wikibox = wikibox .. '| '
		--Crafting 2
		if skillTable.recipes.level2 ~= nil then
			wikibox = wikibox .. '| '		
			if skillTable.recipes.level2 ~= nil then
				for i,v in pairs(skillTable.recipes.level2) do
					wikibox = wikibox .. skillTable.recipes.level2[i] .. '<br />'
				end	
			wikibox = wikibox .. '\n'
			end
		else
			wikibox = wikibox .. '\n'
		end
		--Talent 2
		if anyTalents then
			wikibox = wikibox .. '| '
			if skillTable.talents.level2 ~= nil then	
				if skillTable.talents.level2 ~= nil then
					for i,v in pairs(skillTable.talents.level2) do
						wikibox = wikibox .. skillTable.talents.level2[i] .. '<br />'
					end	
				wikibox = wikibox .. '\n'
				end
			else
				wikibox = wikibox .. '\n'
			end	
		end
		--Benefits 2
		if anyBenefits then
			wikibox = wikibox .. '| '
			if skillTable.benefits.level2 ~= nil then
				wikibox = wikibox .. skillTable.benefits.level2[1] .. ': ' .. skillTable.benefits.level2[2] .. ' the ' .. skillTable.benefits.level2[3] .. ' by ' .. skillTable.benefits.level2[4]
			end
			wikibox = wikibox .. '\n'
		end
		
		--Level 3
		wikibox = wikibox .. '|- \n'
		wikibox = wikibox .. '| 3\n'
		wikibox = wikibox .. '| '
		--Crafting 3
		if skillTable.recipes.level3 ~= nil then
			wikibox = wikibox .. '| '		
			if skillTable.recipes.level3 ~= nil then
				for i,v in pairs(skillTable.recipes.level3) do
					wikibox = wikibox .. skillTable.recipes.level3[i] .. '<br />'
				end	
			wikibox = wikibox .. '\n'
			end
		else
			wikibox = wikibox .. '\n'
		end
		--Talent 3
		if anyTalents then
			wikibox = wikibox .. '| '
			if skillTable.talents.level3 ~= nil then	
				if skillTable.talents.level3 ~= nil then
					for i,v in pairs(skillTable.talents.level3) do
						wikibox = wikibox .. skillTable.talents.level3[i] .. '<br />'
					end	
				wikibox = wikibox .. '\n'
				end
			else
				wikibox = wikibox .. '\n'
			end	
		end
		--Benefits 3
		if anyBenefits then
			wikibox = wikibox .. '| '
			if skillTable.benefits.level3 ~= nil then
				wikibox = wikibox .. skillTable.benefits.level3[1] .. ': ' .. skillTable.benefits.level3[2] .. ' the ' .. skillTable.benefits.level3[3] .. ' by ' .. skillTable.benefits.level3[4]
			end
			wikibox = wikibox .. '\n'
		end

		--Level 4
		wikibox = wikibox .. '|- \n'
		wikibox = wikibox .. '| 4\n'
		wikibox = wikibox .. '| '
		--Crafting 4
		if skillTable.recipes.level4 ~= nil then
			wikibox = wikibox .. '| '		
			if skillTable.recipes.level4 ~= nil then
				for i,v in pairs(skillTable.recipes.level4) do
					wikibox = wikibox .. skillTable.recipes.level4[i] .. '<br />'
				end	
			wikibox = wikibox .. '\n'
			end
		else
			wikibox = wikibox .. '\n'
		end
		--Talent 4
		if anyTalents then
			wikibox = wikibox .. '| '
			if skillTable.talents.level4 ~= nil then	
				if skillTable.talents.level4 ~= nil then
					for i,v in pairs(skillTable.talents.level4) do
						wikibox = wikibox .. skillTable.talents.level4[i] .. '<br />'
					end	
				wikibox = wikibox .. '\n'
				end
			else
				wikibox = wikibox .. '\n'
			end	
		end
		--Benefits 4
		if anyBenefits then
			wikibox = wikibox .. '| '
			if skillTable.benefits.level4 ~= nil then
				wikibox = wikibox .. skillTable.benefits.level4[1] .. ': ' .. skillTable.benefits.level4[2] .. ' the ' .. skillTable.benefits.level4[3] .. ' by ' .. skillTable.benefits.level4[4]
			end
			wikibox = wikibox .. '\n'
		end

		--Level 5
		wikibox = wikibox .. '|- \n'
		wikibox = wikibox .. '| 5\n'
		wikibox = wikibox .. '| '
		--Crafting 5
		if skillTable.recipes.level5 ~= nil then
			wikibox = wikibox .. '| '		
			if skillTable.recipes.level5 ~= nil then
				for i,v in pairs(skillTable.recipes.level5) do
					wikibox = wikibox .. skillTable.recipes.level5[i] .. '<br />'
				end	
			wikibox = wikibox .. '\n'
			end
		else
			wikibox = wikibox .. '\n'
		end
		--Talent 5
		if anyTalents then
			wikibox = wikibox .. '| '
			if skillTable.talents.level5 ~= nil then	
				if skillTable.talents.level5 ~= nil then
					for i,v in pairs(skillTable.talents.level5) do
						wikibox = wikibox .. skillTable.talents.level5[i] .. '<br />'
					end	
				wikibox = wikibox .. '\n'
				end
			else
				wikibox = wikibox .. '\n'
			end	
		end
		--Benefits 5
		if anyBenefits then
			wikibox = wikibox .. '| '
			if skillTable.benefits.level5 ~= nil then
				wikibox = wikibox .. skillTable.benefits.level5[1] .. ': ' .. skillTable.benefits.level5[2] .. ' the ' .. skillTable.benefits.level5[3] .. ' by ' .. skillTable.benefits.level5[4]
			end
			wikibox = wikibox .. '\n'
		end
		
		--Level 6
		wikibox = wikibox .. '|- \n'
		wikibox = wikibox .. '| 6\n'
		wikibox = wikibox .. '| '
		--Crafting 6
		if skillTable.recipes.level6 ~= nil then
			wikibox = wikibox .. '| '		
			if skillTable.recipes.level6 ~= nil then
				for i,v in pairs(skillTable.recipes.level6) do
					wikibox = wikibox .. skillTable.recipes.level6[i] .. '<br />'
				end	
			wikibox = wikibox .. '\n'
			end
		else
			wikibox = wikibox .. '\n'
		end
		--Talent 6
		if anyTalents then
			wikibox = wikibox .. '| '
			if skillTable.talents.level6 ~= nil then	
				if skillTable.talents.level6 ~= nil then
					for i,v in pairs(skillTable.talents.level6) do
						wikibox = wikibox .. skillTable.talents.level6[i] .. '<br />'
					end	
				wikibox = wikibox .. '\n'
				end
			else
				wikibox = wikibox .. '\n'
			end	
		end
		--Benefits 6
		if anyBenefits then
			wikibox = wikibox .. '| '
			if skillTable.benefits.level6 ~= nil then
				wikibox = wikibox .. skillTable.benefits.level6[1] .. ': ' .. skillTable.benefits.level6[2] .. ' the ' .. skillTable.benefits.level6[3] .. ' by ' .. skillTable.benefits.level6[4]
			end
			wikibox = wikibox .. '\n'
		end

		--Level 7
		wikibox = wikibox .. '|- \n'
		wikibox = wikibox .. '| 7\n'
		wikibox = wikibox .. '| '
		--Crafting 7
		if skillTable.recipes.level7 ~= nil then
			wikibox = wikibox .. '| '		
			if skillTable.recipes.level7 ~= nil then
				for i,v in pairs(skillTable.recipes.level7) do
					wikibox = wikibox .. skillTable.recipes.level7[i] .. '<br />'
				end	
			wikibox = wikibox .. '\n'
			end
		else
			wikibox = wikibox .. '\n'
		end
		--Talent 7
		if anyTalents then
			wikibox = wikibox .. '| '
			if skillTable.talents.level7 ~= nil then	
				if skillTable.talents.level7 ~= nil then
					for i,v in pairs(skillTable.talents.level7) do
						wikibox = wikibox .. skillTable.talents.level7[i] .. '<br />'
					end	
				wikibox = wikibox .. '\n'
				end
			else
				wikibox = wikibox .. '\n'
			end	
		end
		--Benefits 7
		if anyBenefits then
			wikibox = wikibox .. '| '
			if skillTable.benefits.level7 ~= nil then
				wikibox = wikibox .. skillTable.benefits.level7[1] .. ': ' .. skillTable.benefits.level7[2] .. ' the ' .. skillTable.benefits.level7[3] .. ' by ' .. skillTable.benefits.level7[4]
			end
			wikibox = wikibox .. '\n'
		end
		wikibox = wikibox .. '|}\n\n'
	end
	
return wikibox
	
end

return p