(Створена сторінка: local p = {} p.row = function( f ) local args = f if f == mw.getCurrentFrame() then args = f:getParent().args else f = mw.getCurrentFrame() end local r...) |
мНемає опису редагування |
||
Рядок 18: | Рядок 18: | ||
local titles = {} |
local titles = {} |
||
for v in mw.text.gsplit( resource, '%s*,%s*' ) do |
for v in mw.text.gsplit( resource, '%s*,%s*' ) do |
||
− | local resources = slot.getParts( v ).name:gsub( '^ |
+ | local resources = slot.getParts( v ).name:gsub( '^Будь-як[иаеі]й? ', '' ) |
table.insert( titles, '[[' .. resources .. ']]' ) |
table.insert( titles, '[[' .. resources .. ']]' ) |
||
end |
end |
Версія за 07:11, 14 червня 2019
local p = {}
p.row = function( f )
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local resource = mw.text.trim( args[1] or '' )
local product = mw.text.trim( args[2] or '' )
local slot = require( 'Модуль:Інвентарний слот' )
local output = {}
local title
if args.title or '' ~= '' then
title = args.title
else
local titles = {}
for v in mw.text.gsplit( resource, '%s*,%s*' ) do
local resources = slot.getParts( v ).name:gsub( '^Будь-як[иаеі]й? ', '' )
table.insert( titles, '[[' .. resources .. ']]' )
end
title = mw.text.listToText( titles )
end
local icon = function( var )
local out = {}
for icons in mw.text.gsplit( var, '%s*,%s*' ) do
table.insert( out, slot.slot{ icons, ['клас'] = 'invslot-plain' } )
end
return table.concat( out )
end
local resourceicon
if resource ~= '' then
resourceicon = '<br>' .. icon( resource )
else
resourceicon = ''
end
table.insert( output, '| style="text-align:center" | ' .. title .. resourceicon )
local align = 'center'
if f:callParserFunction( '#var', 'renewable-method' ) ~= '' then
align = 'left'
end
local products
if args.product or '' ~= '' then
products = args.product
elseif product ~= '' then
products = icon( product )
else
products = '—'
end
table.insert( output, '| style="text-align:' .. align .. '" | ' .. products )
if f:callParserFunction( '#var', 'renewable-method' ) == '' then
table.insert( output, '| ' .. ( args[3] or '' ) )
end
table.insert( output, '|-' )
return table.concat( output, '\n' )
end
return p