Module:Inventory slot/Aliases/Table: Difference between revisions
Jump to navigation
Jump to search
Well it's not that slow, but the table is still ridiculously large. Doesn't seem worth having. |
Combine Any/Matching alias rows |
||
Line 8: | Line 8: | ||
-- Skip the banner aliases (except "Any Banner"), as there are so | -- Skip the banner aliases (except "Any Banner"), as there are so | ||
-- many of them it causes the table to be excessively long | -- many of them it causes the table to be excessively long | ||
if i == 'Any Banner' or not i:find( ' Banner$' ) then | if i == 'Any Banner' or not i:find( ' Banner$' ) and not i:find( '^Matching ' ) then | ||
table.insert( keys, i ) | table.insert( keys, i ) | ||
end | end | ||
Line 28: | Line 28: | ||
end | end | ||
table.insert( tableRows, '| | local aliasText = mw.html.create() | ||
aliasText:tag( 'code' ):wikitext( key ) | |||
if key:find( '^Any ' ) then | |||
aliasText:tag( 'br' ):done() | |||
:tag( 'code' ):wikitext( ( key:gsub( '^Any', 'Matching' ) ) ) | |||
end | |||
table.insert( tableRows, '|' .. tostring( aliasText ) .. '||' .. table.concat( displayCell ) ) | |||
end | end | ||
table.insert( tableRows, '|}' ) | table.insert( tableRows, '|}' ) |
Revision as of 05:33, 2 October 2016
Documentation for this module may be created at Module:Inventory slot/Aliases/Table/doc
local p = {}
p.table = function()
local slot = require( [[Module:Inventory slot]] ).slot
local aliases = mw.loadData( [[Module:Inventory slot/Aliases]] )
local keys = {}
for i in pairs( aliases ) do
-- Skip the banner aliases (except "Any Banner"), as there are so
-- many of them it causes the table to be excessively long
if i == 'Any Banner' or not i:find( ' Banner$' ) and not i:find( '^Matching ' ) then
table.insert( keys, i )
end
end
table.sort( keys )
local tableRows = {
' {| class="wikitable collapsible collapsed"',
'! Alias !! class="collapse-button" | Output'
}
for _, key in ipairs( keys ) do
local alias = aliases[key]
local displayCell = {}
for name in mw.text.gsplit( alias, '%s*;%s*' ) do
-- Aliases are disabled in output for accuracy
-- (as sub-aliases aren't meant to work) and performance
table.insert( displayCell, slot{ name, noalias = true } )
end
local aliasText = mw.html.create()
aliasText:tag( 'code' ):wikitext( key )
if key:find( '^Any ' ) then
aliasText:tag( 'br' ):done()
:tag( 'code' ):wikitext( ( key:gsub( '^Any', 'Matching' ) ) )
end
table.insert( tableRows, '|' .. tostring( aliasText ) .. '||' .. table.concat( displayCell ) )
end
table.insert( tableRows, '|}' )
return table.concat( tableRows, '\n|-\n' )
end
return p