Module:SkillTable: Difference between revisions
From Elwiki
No edit summary |
No edit summary |
||
Line 14: | Line 14: | ||
iterations = 4 | iterations = 4 | ||
end | end | ||
-- Predefine the subpage for mod skills. | |||
local l_mod_subpage = '/ModA' | |||
-- Split into two tables for easier maintenance of the code. | -- Split into two tables for easier maintenance of the code. | ||
Line 83: | Line 86: | ||
-- Spawn regular cells | -- Spawn regular cells | ||
if not (is_header) then | if not (is_header) then | ||
-- Split images for situations with multiple icons. | |||
local full_name = name; | local full_name = name; | ||
image = split(image, '\\'); | image = split(image, '\\'); | ||
Line 93: | Line 97: | ||
end | end | ||
-- Set a display name if there is more than one image. | |||
if (#image > 1 and #name > 1) then | if (#image > 1 and #name > 1) then | ||
image_cell:addClass('skill-columns'); | image_cell:addClass('skill-columns'); | ||
Line 103: | Line 108: | ||
end | end | ||
-- Iterate through split icons. | |||
while index <= #image do | while index <= #image do | ||
image[index] = trim(image[index]); | image[index] = trim(image[index]); | ||
name[index] = trim(name[index]); | name[index] = trim(name[index]); | ||
-- Mod skills | -- Mod skills | ||
if (string.find(name[index], '/Mod')) then | if (string.find(name[index], '/Mod')) then | ||
name[index] = name[index]:gsub('%/Mod', ''); | name[index] = name[index]:gsub('%/Mod', ''); | ||
mod_subpage = | mod_subpage = l_mod_subpage; | ||
else | else | ||
mod_subpage = '' | mod_subpage = '' | ||
end | end | ||
-- Decide which icon to spawn based on being a [Mod] or not. | |||
if (mod_subpage == '') then | if (mod_subpage == '') then | ||
image_cell:wikitext('[[File:' .. image[index] .. '|link=' .. name[index] .. ']]') | image_cell:wikitext('[[File:' .. image[index] .. '|link=' .. name[index] .. ']]') | ||
Line 123: | Line 132: | ||
index = index + 1 | index = index + 1 | ||
end | end | ||
if (full_name:match('/Mod')) then | if (full_name:match('/Mod')) then | ||
full_name = full_name:gsub('/Mod', ''); | full_name = full_name:gsub('/Mod', ''); | ||
mod_subpage = | mod_subpage = l_mod_subpage | ||
end | end | ||
-- Spawn a name cell. | |||
local name_cell = row:tag('div'):attr('data-type', 'table-cell'); | local name_cell = row:tag('div'):attr('data-type', 'table-cell'); | ||
local skill_wrap = name_cell:tag('div'):addClass('skill-wrap'); | local skill_wrap = name_cell:tag('div'):addClass('skill-wrap'); |