Pcj (обсуждение | вклад) Нет описания правки |
Pcj (обсуждение | вклад) Нет описания правки |
||
Строка 43: | Строка 43: | ||
return p |
return p |
||
− | --test |
Версия от 13:58, 17 апреля 2018
▶️
Planeshift.
Документацию для этого шаблона или модуля можно найти в Шаблон:Build order.
Вы можете быть перенаправлены на другой язык вики, если перевод недоступен.
local cargo = mw.ext.cargo
local getArgs = require( 'Module:Arguments' ).main
local p = {}
function p.main( frame )
local args = getArgs()
return p._main( args )
end
function p._main( args )
local title = args['title'] or 'Изучение способностей'
-- The hero arg is currently not used.
local hero = args['hero'] or mw.title.getCurrentTitle().baseText
-- Creates a table with the format ["Ability"] = "image"
local abilities = { ["Талант"]="File:Talent icon.png" }
for k,v in pairs( cargo.query( 'abilities', 'title, image', { where='_pageName="' .. hero .. '"', groupBy='source, title' } ) ) do
abilities[v['title']] = v['image']
end
-- Creates 2 tables: One with the number of each level and one with a formatted image link.
local levels, images = {}, {}
for i=1,25 do
if args['lvl' .. i] then
local image = abilities[args['lvl' .. i]] or 'File:Unknown icon.png'
table.insert( images, '[[' .. image .. '|40px|link=' .. hero .. '#' .. args['lvl' .. i] .. ']]' )
table.insert( levels, i )
end
end
-- For some reason \n doesn't work here so I'm using double line-breaks instead.
return [[{| class="wikitable" style="text-align:center;"
! class="header" colspan="25" | ]] .. title .. [[
|-
|]] .. table.concat( levels, '||' ) .. [[
|-
|]] .. table.concat( images, '||' ) .. [[
|}]]
end
return p