Module:SkillNav
From Elwiki
Documentation for this module may be created at Module:SkillNav/doc
require('Module:CommonFunctions')
local getArgs = require('Module:Arguments').getArgs
local p = {}
-- Main process
function p.main(frame)
local args = getArgs(frame);
function inArgs(name)
if (inArray(name, args)) then
return true
end
end
local skill_types = {
[1] = {
['name'] = 'Hyper Active',
['abbr'] = 'HA'
},
[2] = {
['name'] = 'Secret Art',
['abbr'] = 'SeA'
},
[3] = {
['name'] = 'Special Active',
['abbr'] = 'SA'
},
[4] = {
['name'] = 'Active',
['abbr'] = 'A'
},
[5] = {
['name'] = 'Force Mod',
['abbr'] = 'FC'
},
[6] = {
['name'] = 'Buff',
['abbr'] = 'B'
},
[7] = {
['name'] = 'Passive',
['abbr'] = 'P'
},
[8] = {
['name'] = 'Manic Demon',
['abbr'] = 'MD'
},
[9] = {
['name'] = '[[File:ForceIcon.png|16px]] Manic Demon',
['abbr'] = 'MDF'
},
[10] = {
['name'] = 'Master Skill',
['abbr'] = 'MS'
},
[11] = {
['name'] = 'Couple Skill',
['abbr'] = 'Wed'
}
}
local out = ''
local skill_nav = mw.html.create('div'):addClass('skill-nav');
local header = skill_nav:tag('div'):addClass('skill-nav-header')
header:attr('style', 'background-color:' .. frame:expandTemplate{
title = 'ColorSel',
args = {'Character', args.char}
}):wikitext(frame:expandTemplate{
title = 'Face',
args = {
args.char,
args.pic,
link = args.name,
scale = '0.75'
}
})
header:tag('span'):wikitext('[[' .. args.name .. ']] - Skills')
local skill_nav_wrap = skill_nav:tag('div'):addClass('skill-nav-inner-wrap border-color');
for k2, v2 in spairs(skill_types) do
local name = v2['name'];
local abbr = v2['abbr'];
if (inArgs(abbr)) then
local skills = split(args[abbr], ';');
if (abbr == 'Wed') then
skills = {'CSZE.png', 'Extreme Heavenly Love'}
end
local mc_skill_name = ''
local mc_skill_name_head = ''
if (abbr == 'MS') then
mc_skill_name = skills[5]
mc_skill_name_head = '<br/>- ' .. mc_skill_name .. ''
skills[7] = skills[4]
skills[5] = skills[3]
skills[3] = skills[2]
skills[8] = mc_skill_name .. '/Stage 4|Stage 4'
skills[6] = mc_skill_name .. '/Stage 3|Stage 3'
skills[4] = mc_skill_name .. '/Stage 2|Stage 2'
skills[2] = mc_skill_name .. '/Stage 1|Stage 1'
end
local i = 1;
skill_nav_wrap:tag('div'):addClass('skill-nav-sub-head border-color tone-4'):wikitext(name ..
mc_skill_name_head);
local content = skill_nav_wrap:tag('div'):addClass('skill-nav-skill-content border-color tone-6');
local entry_classes = 'skill-nav-skill tone-7-hover color-normal-force-link tone-8-active';
for k, v in pairs(skills) do
if v == nil then
return
end
if (i % 2 == 0) then
local skill_entry = content:tag('div'):addClass(entry_classes);
local skill_icon = skill_entry:tag('div'):addClass('skill-nav-image')
if (abbr == 'FC' or abbr == 'MDF') then
skill_entry:wikitext('[[' .. v .. '/ModA|' .. v .. ']]');
skill_icon:wikitext(frame:expandTemplate{
title = 'Force',
args = {
trim(skills[i - 1]),
link = v,
size = '3'
}
});
else
skill_entry:wikitext('[[' .. v .. ']]');
skill_icon:wikitext('[[File:' .. trim(skills[i - 1]) .. '|30px|link= ' .. v .. ']]');
end
end
i = i + 1;
end
end
end
local force_nav = ''
if (args.FS == 'true') then
force_nav = frame:expandTemplate{
title = 'ForceSkillNav',
args = {
Class = 'mw-collapsible mw-collapsed',
Color = frame:expandTemplate{
title = 'ColorSel',
args = {'Character', args.char}
}
}
}
end
return tostring(skill_nav) .. force_nav;
end
return p