Module:CreaturePaintTable
Jump to navigation
Jump to search
Documentation for this module may be created at Module:CreaturePaintTable/doc
local Arkitecture = require( 'Module:Arkitecture' )
local WrapText = Arkitecture.WrapText
local Html = Arkitecture.Html
local ItemLink = require( 'Module:ItemLink' )
local Utility = require( 'Module:Utility' )
return Arkitecture.makeRenderer{
RequiredLibraries = {
'Module:Arkitecture/Common library',
},
Parameters = {},
wrapRendered = function ( self, html )
return html
end,
getSetup = function ( self, ctx )
local gameIcons = {
["ARK: Survival Ascended"] = mw.getCurrentFrame():expandTemplate{
title = 'Template:Gameicon',
args = { 'sa' },
},
["ARK: Survival Evolved"] = mw.getCurrentFrame():expandTemplate{
title = 'Template:Gameicon',
args = { 'se' },
},
}
local records = mw.ext.cargo.query(
'CreaturePaint',
'ObjectGame, ObjectName, Id, Name',
{
orderBy = 'ObjectName ASC, Id ASC',
limit = 9999,
}
)
local aggregated = {}
for _, record in pairs( records ) do
local virtualKey = record.ObjectGame .. record.ObjectName
if not aggregated[ virtualKey ] then
aggregated[ virtualKey ] = {
GameIcon = gameIcons[ record.ObjectGame ],
Name = record.ObjectName,
}
end
local row = aggregated[ virtualKey ]
row[ record.Id ] = record.Name
end
local results = {}
for _, record in pairs( aggregated ) do
results[ #results + 1 ] = Html.Element{
tag = 'tr',
WrapText( 'td', record.GameIcon ),
WrapText( 'td', ItemLink.create( record.Name ) ),
WrapText( 'td', record["0"] ) or '<td></td>',
WrapText( 'td', record["2"] ) or '<td></td>',
WrapText( 'td', record["3"] ) or '<td></td>',
WrapText( 'td', record["1"] ) or '<td></td>',
WrapText( 'td', record["4"] ) or '<td></td>',
WrapText( 'td', record["5"] ) or '<td></td>',
}
end
return results
end
}