Editing Module:Infobox Skill
From Eco - English Wiki
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
-- Grabs args from the parent frame | -- Grabs args from the parent frame | ||
Line 20: | Line 17: | ||
end | end | ||
-- | -- Build an Infobox_Skill | ||
if | 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 | end | ||
local skill = args.name | |||
local skillimagename = string.gsub(skill, ' ', '') | |||
local skillTable = skillData.skills[skill] | |||
if skillTable == nil then | |||
return skill .. ' could not be found in Module:TSkills.' | |||
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 | ||
infobox = infobox .. '|- style=\"color: white; background-color: #1165AF; text-align: center;\"\n| colspan=\"2\" | \'\'\'<big>' .. | infobox = infobox .. '|- style=\"color: white; background-color: #1165AF; text-align: center;\"\n| colspan=\"2\" | \'\'\'<big>' .. skill .. '</big>\'\'\'\n' | ||
-- Prof,Spec,Skill box | |||
infobox = infobox .. '|- style=\"text-align: center;color: white; background-color: goldenrod;\"\n| colspan=\"2\"' | |||
if skillTable.root == true then | if skillTable.root == true then | ||
infobox = infobox .. '| \'\'\'Profession\'\'\' | infobox = infobox .. '| \'\'\'Profession\'\'\'\n' | ||
elseif skillTable.specialty == true then | elseif skillTable.specialty == true then | ||
infobox = infobox .. '| \'\'\'Specialty\'\'\' | infobox = infobox .. '| \'\'\'Specialty\'\'\'\n' | ||
else | |||
infobox = infobox .. '| \'\'\' | infobox = infobox .. '| \'\'\'Skill\'\'\'\n' | ||
end | |||
-- Skill Icon Image | |||
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 | end | ||
infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | <div class="iconContainer"><div class="iconStack">[[File:' .. image .. '|frameless|class=iconOrange]]</div><div class=iconBorder style=\"position:absolute;\"></div></div> \n' | |||
-- 'Description' section header | |||
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Description\'\'\'\n' | infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Description\'\'\'\n' | ||
Line 102: | Line 71: | ||
end | end | ||
-- | |||
if | -- 'Related Skills' section header | ||
infobox = infobox .. '|- style=\"background-color: #4688C0; 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; padding: 3px;\" | ' .. skillTable.rootSkill .. '\n' | |||
end | |||
-- Specialty .specialitySkill | |||
if skillTable.specialitySkill ~= nil then | |||
infobox = infobox .. '|-\n| Specialty:\n| style=\"text-align: right; padding: 3px;\" | ' .. skillTable.specialitySkill .. '\n' | |||
end | |||
-- Skills Required .prerequisites | |||
if skillTable.prerequisites ~= nil then | |||
infobox = infobox .. '|-\n| Skills Required:\n| style=\"text-align: right; padding: 3px;\" |[[ ' .. skillTable.prerequisites .. ']]\n' | |||
end | |||
-- Leads to childSkills | |||
if skillTable.childSkills ~= nil then | |||
infobox = infobox .. '|-\n| Leads to:\n| style=\"text-align: right; padding: 3px;\" | ' .. skillTable.childSkills .. '\n' | |||
end | |||
-- 'Skill Information' section header | |||
infobox = infobox .. '|- style=\"background-color: #4688C0; 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; padding: 3px;\" | Level ' .. skillTable.maxLevel .. '\n' | |||
end | |||
-- items given .itemsGiven | |||
if skillTable.itemsGiven ~= nil then | |||
infobox = infobox .. '|-\n| Items Given:\n| style=\"text-align: right; padding: 3px;\" | ' .. skillTable.itemsGiven .. '\n' | |||
end | |||
-- 'IDs' section header | |||
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'IDs\'\'\'\n' | |||
-- skill id (type) | |||
infobox = infobox .. '|- valign=\"center\"\n| Item ID:\n| style=\"text-align: right; padding: 3px;\" | ' .. skillTable.skillID .. '\n' | |||
-- id number (type id) | |||
infobox = infobox .. '|- valign=\"center\"\n| ID Number:\n| style=\"text-align: right; padding: 3px;\" | ' .. skillTable.skillIDNum .. '\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 |