Module:Inventory slot/Aliases/Table: Difference between revisions

updated to the version on minecraft.wiki
(Created page with "local p = {} p.table = function() local slot = require( Module:Inventory slot ) local aliases = mw.loadData( Module:Inventory slot/Aliases ) local aliasNames = {} local aI = 1 for name 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 name == 'Any Banner' or not name:find( ' Banner$' ) and not name:find( '^Matching ' ) then aliasNames[aI] = name...")
 
(updated to the version on minecraft.wiki)
Line 3:
local slot = require( [[Module:Inventory slot]] )
local aliases = mw.loadData( [[Module:Inventory slot/Aliases]] )
 
local aliasNames = {}
local aI = 1
Line 9:
-- Skip the banner aliases (except "Any Banner"), as there are so
-- many of them it causes the table to be excessively long
if
if name == 'Any Banner' or not name:find( ' Banner$' ) and not name:find( '^Matching ' ) then
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
Line 15 ⟶ 20:
end
table.sort( aliasNames )
 
local tableRows = {
' {| class="wikitable collapsible collapsed"',
Line 23 ⟶ 28:
for _, name in ipairs( aliasNames ) do
local alias = slot.getAlias( aliases[name], {} )
 
local cell = {}
for i, frame in ipairs( alias ) do
cell[i] = slot.slot{ { frame }, parsed = true }
end
 
local aliasText = mw.html.create()
aliasText:tag( 'code' ):wikitext( name )
if name:find( '^Any ' ) then
:tag(local 'code'altName ):wikitext( (= name:gsub( '^Any', 'Matching' ) ) )
aliasText:tag( 'br' ):done()
if aliases[altName] then
:tag( 'code' ):wikitext( ( name:gsub( '^Any', 'Matching' ) ) )
aliasText:tag( 'br' ):done()
:tag( 'code' ):wikitext( altName )
end
end
 
tableRows[rI] = '|' .. tostring( aliasText ) .. '||' .. table.concat( cell )
rI = rI + 1
end
tableRows[rI] = '|}'
 
return table.concat( tableRows, '\n|-\n' )
end