Module:Inventory slot/Aliases/Table: Difference between revisions
But I think we can allow "Any Banner". |
m 1 revision imported |
||
| (10 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
p.table = function() | p.table = function() | ||
local | local slot = require( [[Module:Inventory slot]] ) | ||
local aliases = mw.loadData( [[Module: | local aliases = mw.loadData( [[Module:Inventory slot/Aliases]] ) | ||
local | local aliasNames = {} | ||
for | local aI = 1 | ||
-- Skip the banner aliases (except "Any Banner"), as there are so many of them it | for name in pairs( aliases ) do | ||
-- Skip the banner aliases (except "Any Banner"), as there are so | |||
if | -- many of them it causes the table to be excessively long | ||
if | |||
name == 'Any Banner' or | |||
not name:find( ' Banner$' ) and | |||
not name:find( '^Matching ' ) or | |||
not aliases[name:gsub( '^Matching', 'Any' )] | |||
then | |||
aliasNames[aI] = name | |||
aI = aI + 1 | |||
end | end | ||
end | end | ||
table.sort( | table.sort( aliasNames ) | ||
local tableRows = { | local tableRows = { | ||
' {| class="wikitable collapsible collapsed"', | ' {| class="wikitable collapsible collapsed"', | ||
'! Alias !! | '! Alias !! Output' | ||
} | } | ||
for _, | local rI = #tableRows + 1 | ||
local alias = aliases[ | for _, name in ipairs( aliasNames ) do | ||
local alias = slot.getAlias( aliases[name], {} ) | |||
local | |||
for | local cell = {} | ||
for i, frame in ipairs( alias ) do | |||
cell[i] = slot.slot{ { frame }, parsed = true } | |||
end | end | ||
local aliasText = mw.html.create() | |||
aliasText:tag( 'code' ):wikitext( name ) | |||
if name:find( '^Any ' ) then | |||
local altName = name:gsub( '^Any', 'Matching' ) | |||
if aliases[altName] then | |||
aliasText:tag( 'br' ):done() | |||
:tag( 'code' ):wikitext( altName ) | |||
end | |||
end | |||
tableRows[rI] = '|' .. tostring( aliasText ) .. '||' .. table.concat( cell ) | |||
rI = rI + 1 | |||
end | end | ||
tableRows[rI] = '|}' | |||
return table.concat( tableRows, '\n|-\n' ) | return table.concat( tableRows, '\n|-\n' ) | ||
end | end | ||
return p | return p | ||