Module:Inventory slot/Aliases/Table: Difference between revisions
Jump to navigation
Jump to search
m Majr moved page Module:Grid/Aliases/Table to Module:Inventory slot/Aliases/Table without leaving a redirect |
No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
p.table = function() | p.table = function() | ||
local | local slot = require( [[Module:Inventory slot]] ).slot | ||
local aliases = mw.loadData( [[Module: | local aliases = mw.loadData( [[Module:Inventory slot/Aliases]] ) | ||
local keys = {} | local keys = {} | ||
for i in pairs( aliases ) do | for i in pairs( aliases ) do | ||
table.insert( keys, i ) | |||
end | end | ||
table.sort( keys ) | table.sort( keys ) | ||
Line 25: | Line 21: | ||
-- Aliases are disabled in output for accuracy | -- Aliases are disabled in output for accuracy | ||
-- (as sub-aliases aren't meant to work) and performance | -- (as sub-aliases aren't meant to work) and performance | ||
table.insert( displayCell, | table.insert( displayCell, slot{ name, noalias = true } ) | ||
end | end | ||
Revision as of 05:30, 21 August 2015
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
table.insert( keys, i )
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
table.insert( tableRows, '|<code>' .. key .. '</code>||' .. table.concat( displayCell ) )
end
table.insert( tableRows, '|}' )
return table.concat( tableRows, '\n|-\n' )
end
return p