Module:User:AttemptToCallNil/Test

local p = {} local aliases = mw.loadData("Module:Inventory slot/Aliases")

function p.dumpAliasElement(element) local elementAsString = {} table.insert(elementAsString, '{ ') if element.title then table.insert(elementAsString, 'title = "' .. element.title .. '", ') end if element.name then table.insert(elementAsString, 'name = "' .. element.name .. '", ') end if element.text then table.insert(elementAsString, 'text = "' .. element.text .. '"') end table.insert(elementAsString, ' }') return (table.concat(elementAsString):gsub(", }", " }")) end

function p.dumpAliases local result = {} table.insert(result, ' ') table.insert(result, '{') for name, alias in pairs(aliases) do local line = {'   ["' .. name .. '"] = '} if type(alias) == 'string' then table.insert(line, '"' .. alias .. '"') elseif type(alias) == 'table' then table.insert(line, '{ ') if alias[1] then for _, aliasElement in ipairs(alias) do					if type(aliasElement) == 'string' then table.insert(line, '"' .. aliasElement .. '", ') elseif type(aliasElement) == 'table' then table.insert(line, p.dumpAliasElement(aliasElement)) end end else table.insert(line, p.dumpAliasElement(alias)) end table.insert(line, ' }') end table.insert(line, ',') table.insert(result, (table.concat(line):gsub(", }", " }"):gsub("{ {", "{"):gsub("} }", "}"))) end table.insert(result, '}') table.insert(result, ' ') return table.concat(result, '\n') end

return p