Warning.png

Поддержка Wiki прекращена, она доступна в режиме архива. Информация в ней устарела и может быть неактуальной.

Изменения

Перейти к: навигация, поиск

Модуль:Варка

5876 байтов добавлено, 13:26, 12 августа 2016
Новая страница: «local p = {} function p.table( f ) local args = f if f == mw.getCurrentFrame() then args = f:getParent().args else f = mw.getCurrentFrame() end local get…»
local p = {}
function p.table( f )
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local getParts = require( 'Модуль:Инвентарный слот' ).getParts

-- Начинать таблицу при необходимости
local multirow = f:callParserFunction( '#dplvar', 'multirow' )
if multirow ~= '1' then
multirow = nil
end
local head = args["глава"] or ''
if multirow then
head = ''
elseif head ~= '' then
multirow = 1
f:callParserFunction( '#dplvar:set', 'multirow', '1' )
else
head = 1
end

-- Заканчивать таблицу при необходимости
local foot = args["подвал"] or ''
if multirow then
if foot ~= '' then
multirow = nil
f:callParserFunction( '#dplvar:set', 'multirow', '0' )
end
else
foot = 1
end

local header = ''
if head ~= '' then
local name = ''
local description = ''
if args["показатьимя"] == '1' or multirow and args["показатьимя"] ~= '0' then
name = 'Name !! '
f:callParserFunction( '#dplvar:set', 'brewingname', '1' )
end
if args["показатьописание"] == '1' then
description = ' !! class="unsortable" | Description'
f:callParserFunction( '#dplvar:set', 'brewingdescription', '1' )
end
local class = args["класс"] or ''
local recipeClass = ''
if multirow then
class = 'sortable collapsible ' .. class
recipeClass = 'class="unsortable" |'
end
header = table.concat( {
' {| class="wikitable ' .. class .. '" data-description="Рецепты варки"',
'! ' .. name .. 'Ингридиенты !! ' .. recipeClass .. ' Рецепты [[Зельеварение|варки]]' .. description,
'|-'
}, '\n' )
end

local input = mw.text.trim( args[1] or '' )
local output2 = mw.text.trim( args[2] or '' )
local base = args['основа'] or ''
if base == '' then
base = 'Грубое зелье'
end

-- Name cell
local nameCell
if args.name or '' ~= '' then
nameCell = args["название"]
elseif multirow or f:callParserFunction( '#dplvar', 'brewingname' ) == '1' then
local names = {}
local links = {}
for v in mw.text.gsplit( args[2] or '', '%s*;%s*' ) do
parts = getParts( v )
if not names[( parts.mod or '' ) .. parts.name] then
local link = ''
if parts.mod then
link = parts.mod .. '/' .. parts.name .. '|'
end

if parts.name:find( '^Люб' ) then
table.insert( links, mw.ustring.sub( parts.name, 0, 6 ) .. '[[' .. link .. mw.ustring.sub( parts.name, 6 ) .. ']]' )
else
table.insert( links, '[[' .. link .. parts.name .. ']]' )
end
names[( parts.mod or '' ) .. parts.name] = 1
end
end

nameCell = table.concat( links, '&nbsp;или<br>' )
end

if nameCell and args["запланированное"] then
nameCell = nameCell .. '<br>([[' .. args["запланированное"] .. ']])'
end

-- Ячейка с ингредиентами
local ingredientsCell
if args["ингредиенты"] or '' ~= '' then
ingredientsCell = args["ингредиенты"]
else
ingredientsCell = {}
local ingredients = {}
for k, v in ipairs{ input, base } do
local separator = ''
if k == 2 and next( ingredients ) then
separator = '&nbsp;+<br>\n'
end
for item in mw.text.gsplit( v, '%s*;%s*' ) do
local parts = getParts( item )
if parts.name ~= '' and not ingredients[parts.name] and ( k == 2 or k == 1 and v ~= base ) then
local link = ''
if separator == '' and next( ingredients ) then
separator = '&nbsp;или<br>\n'
end

if parts.mod then
link = parts.mod .. '/' .. parts.name .. '|'
end

if parts.name:find( '^Люб' ) then
table.insert( ingredientsCell, separator .. mw.ustring.sub( parts.name, 0, 6 ) .. '[[' .. link .. mw.ustring.sub( parts.name, 6 ) .. ']]' )
else
table.insert( ingredientsCell, separator .. '[[' .. link .. parts.name .. ']]' )
end
separator = ''

ingredients[parts.name] = 1
end
end
end

ingredientsCell = table.concat( ingredientsCell )
end

-- Whether to show base or output
local newArgs = {}
if args["показатьоснову"] == '1' then
newArgs["выход2"] = base
newArgs["выход1"] = args["основа2"]
newArgs["выход3"] = args["основа3"]
else
newArgs["выход2"] = args[2]
newArgs["выход1"] = args[3]
newArgs["выход3"] = args[4]
end

-- Any other args we want to pass along
newArgs["основа"] = args[1]
newArgs["оназв"] = args["оназв"]
newArgs["в2назв"] = args["вназв"]
newArgs["в1назв"] = args["в2назв"]
newArgs["в3назв"] = args["в3назв"]

-- Ячейка с рецептом
local recipeCell = require( 'Модуль:Интерфейс' ).brewingStand( newArgs )

local row = {
'\n' .. ingredientsCell,
'style="padding:1px" |\n' .. recipeCell
}
if nameCell then
table.insert( row, 1, nameCell )
end
local descriptionCell = args["описание"] or ''
if f:callParserFunction( '#dplvar', 'brewingdescription' ) == '1' then
table.insert( row, descriptionCell )
end
row = table.concat( row, '\n|' )

if nameCell then
row = '!\n' .. row
else
row = '|\n' .. row
end

local footer = ''
if foot ~= '' then
footer = '|}'
f:callParserFunction( '#dplvar:set', 'brewingname', '0', 'brewingdescription', '0' )
end

local title = mw.title.getCurrentTitle()
local category = ''
if args["запланированное"] and args["некат"] ~= '1' and title.namespace == 0 and not title.isSubpage then
category = '[[Категория:Запланированное]]'
end

return header .. '\n' .. row .. '\n|-\n' .. footer .. category
end
return p

Навигация