Module:Variants: Difference between revisions

For equiptment with grades, show "Grade N" as the variant name
m (spaces to tabs)
(For equiptment with grades, show "Grade N" as the variant name)
Line 37:
local formatted = {}
for _, entry in ipairs(smw_data) do
iflocal variant_name = entry['Variant name'] then
if variant_name then
local page = entry[1]
local pipe = page:find('|')
Line 45 ⟶ 46:
page = page:sub(3, -3)
end
 
table.insert(formatted, ('[[%s|%s]]'):format(page, entry['Variant name']))
if page:sub(1, 1 + #variant_name + #' (grade ') == ':' .. variant_name .. ' (grade ' and page:sub(-1) == ')' then
local grade_number = page:sub(2 + #variant_name + #' (grade ', -2)
mw.log('"' .. grade_number .. '"')
variant_name = 'Grade ' .. grade_number
end
 
table.insert(formatted, ('[[%s|%s]]'):format(page, entry['Variant name']variant_name))
else
table.insert(formatted, entry[1])
698

edits