ElEditors, Interface administrators, Administrators
70,980
edits
No edit summary |
No edit summary |
||
(21 intermediate revisions by the same user not shown) | |||
Line 14: | Line 14: | ||
iterations = 4 | iterations = 4 | ||
end | end | ||
-- Predefine the subpage for mod skills. | |||
local l_mod_subpage = '/ModA' | |||
local lang = args.lang and ('/' .. args.lang) or '' | |||
-- Split into two tables for easier maintenance of the code. | -- Split into two tables for easier maintenance of the code. | ||
Line 28: | Line 33: | ||
if (index % 2 == 0) then | if (index % 2 == 0) then | ||
-- Skill names | -- Skill names | ||
table.insert(skill_name_table, v); | table.insert(skill_name_table, v ~= '' and v or 'Unreleased'); | ||
else | else | ||
-- Image names | -- Image names | ||
Line 46: | Line 51: | ||
local mod_subpage = '' | local mod_subpage = '' | ||
local cube = '' | local cube = '' | ||
local prefix = '' | |||
local suffix = '' | |||
-- Locked skills | -- Locked skills | ||
Line 55: | Line 62: | ||
args = {lock_arg} | args = {lock_arg} | ||
} | } | ||
end | end | ||
Line 68: | Line 69: | ||
local cube_arg = string.sub(name, j); | local cube_arg = string.sub(name, j); | ||
name = name:gsub('%sModCube[0-9]', ''); | name = name:gsub('%sModCube[0-9]', ''); | ||
cube = frame: | cube = frame:expandTemplate{ | ||
title = 'Mod Cube', | |||
args = {cube_arg} | |||
} | |||
end | end | ||
Line 89: | Line 90: | ||
-- Spawn regular cells | -- Spawn regular cells | ||
if not (is_header) then | if not (is_header) then | ||
local image_cell = row:tag('div'):attr('data-type', 'table-cell | -- Split images for situations with multiple icons. | ||
if ( | local full_name = name; | ||
image_cell: | image = split(image, '\\'); | ||
-- Remove prefix, suffix and full name syntax from the display name | |||
name = split(name:gsub('%s?#%s?.*', ''):gsub('^.*%+%+', ''), '\\'); | |||
local index = 1; | |||
local image_cell = row:tag('div'):attr('data-type', 'table-cell'); | |||
if (args.skill_columns ~= nil) then | |||
image_cell:attr('style', 'grid-template-columns: repeat(' .. args.skill_columns .. ', auto)'); | |||
end | end | ||
local | |||
-- Set a display name if there is more than one image. | |||
if (#image > 1 and #name > 1) then | |||
image_cell:addClass('skill-columns'); | |||
local name_match = full_name:match('%s?#%s?(.*)'); | |||
if (name_match ~= nil) then | |||
full_name = name_match; | |||
else | |||
full_name = name[1] | |||
end | |||
end | |||
-- Iterate through split icons. | |||
while index <= #image do | |||
image[index] = trim(image[index]); | |||
name[index] = trim(name[index]); | |||
-- Mod skills | |||
if (string.find(name[index], '/Mod')) then | |||
name[index] = name[index]:gsub('%/Mod', ''); | |||
mod_subpage = l_mod_subpage; | |||
else | |||
mod_subpage = '' | |||
end | |||
-- Decide which icon to spawn based on being a [Mod] or not. | |||
if (mod_subpage == '') then | |||
image_cell:wikitext('[[File:' .. image[index] .. '|link=' .. name[index] .. ']]') | |||
else | |||
image_cell:wikitext(frame:expandTemplate{ | |||
title = 'Force', | |||
args = {image[index], link = name[index]} | |||
}); | |||
end | |||
index = index + 1 | |||
end | |||
if (full_name:match('/Mod')) then | |||
full_name = full_name:gsub('/Mod', ''); | |||
mod_subpage = l_mod_subpage | |||
end | |||
-- Prefixes and suffixes | |||
if (full_name:match('++')) then | |||
prefix = full_name:match('^(.*)%+%+'); | |||
full_name = trim(full_name:gsub('^.*%+%+', '')); | |||
end | |||
if (full_name:match('##')) then | |||
suffix = full_name:match('##(.*)$'); | |||
full_name = trim(full_name:gsub('##.*$', '')); | |||
end | |||
-- Spawn a name cell. | |||
local link = full_name .. mod_subpage .. lang | |||
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'); | ||
skill_wrap:wikitext('[[' .. | skill_wrap:wikitext('[[' .. link .. '|.]]'); | ||
local display_name = | -- Remove (Elsword), (Elesis), etc. in display name | ||
local display_name = full_name:gsub("%s%([%w%s%/]+%)", ""); | |||
if not (mod_subpage == '') then | if not (mod_subpage == '') then | ||
display_name = '[Mod] ' .. display_name; | display_name = '[Mod] ' .. display_name; | ||
end | |||
-- Remove the name of the Master Skill | |||
if (args.no_mc_names == 'true') then | |||
display_name = display_name:gsub('.*%/Stage%s([0-9])', 'Stage %1'); | |||
end | end | ||
skill_wrap:tag('div'):addClass('skill-wrap-text'):wikitext('[[' .. | skill_wrap:tag('div'):addClass('skill-wrap-text'):wikitext('[[' .. link .. '|' .. prefix .. display_name .. ']] ' .. suffix .. lock .. cube ); | ||
-- If a header is detected, it will not interrupt chunking. | -- If a header is detected, it will not interrupt chunking. | ||
Line 121: | Line 185: | ||
} | } | ||
end | end | ||
row = skill_table:tag('div'):attr('data-type', 'table-row'):attr('style', 'background-color: ' .. color):addClass('textfloat table-head'); | |||
if (color == '#') then | if (color == '#') then | ||
row:addClass('related-title') | |||
end | end | ||
row:tag('div'):attr('data-type', 'table-head'):wikitext(name); | row:tag('div'):attr('data-type', 'table-head'):wikitext(name); | ||
end | end |