▶️
Planeshift.
A documentação deste módulo pode ser encontrada em Predefinição:Show.
Você pode ser redirecionado para uma wiki em outro idioma, se de não houver tradução disponível.
local p = {}
local cargoQuery = mw.ext.cargo.query
local getArgs = require( 'Módulo:Arguments' ).getArgs
local i18n = {
error = {
incompleteInput = 'Missing or incomplete input'
},
stringLowerFunc = string.lower -- Change to mw.ustring.lower on wikis using non-latin characters.
}
local function preprocessProperty( property )
property = i18n.stringLowerFunc( property )
property = property:gsub( ' ', '_' )
return property
end
local function query( table, page, property )
property = preprocessProperty( property )
return cargoQuery( table, property, {
where = string.format( '_pageName="%s"', page ),
groupBy = '_pageID'
} )[1][property]
end
function p.main( frame )
local args = getArgs( frame, { wrappers = { 'Template:Show' } } )
return p._main( args )
end
function p._main( args )
assert( args[1] and args[2] and args[3], i18n.error.incompleteInput )
local type = i18n.stringLowerFunc( args[1] )
if type == 'h' then
return query( 'heroes', args[2], args[3] )
elseif type == 't' then
return query( 'talents', args[2] .. '/Talentos', args[3] )
elseif type == 'i' then
return query( 'items', args[2], args[3] )
elseif type == 'u' then
return query( 'units', args[2], args[3] )
elseif type == 'c' then
return query( 'camps', args[2], args[3] )
elseif type == 'a' then
assert( args[4], i18n.error.incompleteInput )
local property = preprocessProperty( args[4] )
if property:find( 'trait' ) or property:find( 'value' ) then
return cargoQuery( 'abilities_traits', property, {
where = string.format( 'uid="%s&%s"', args[2], args[3] ),
groupBy = 'uid'
} )[1][property]
elseif property:find( 'buff' ) or property:find( 'debuff' ) then
return cargoQuery( 'abilities_buffs', property, {
where = string.format( 'uid="%s&%s"', args[2], args[3] ),
groupBy = 'uid'
} )[1][property]
else
return cargoQuery( 'abilities', property, {
where = string.format( 'uid="%s&%s"', args[2], args[3] ),
groupBy = 'source, title'
} )[1][property]
end
end
end
return p