Warning.png

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

Изменения

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

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

3206 байтов убрано, 19:05, 15 октября 2018
м
Нет описания правки
local p = {}
local slot = require( 'Модуль:Инвентарный слот' )
local getParts = slot.getParts
local prefixes = slot.prefixes
local function prefixedLink( name, mod )
local prefix = ''
for _, thisPrefix in pairs( prefixes ) do
if mw.ustring.find(name, '^' .. thisPrefix .. ' ' ) then
prefix = thisPrefix .. ' '
name = mw.ustring.gsub(name, '^' .. prefix, '' )
break
end
end
local page = ''
if mod and mod ~= '' then
page = mod .. '/'
end
 
local vanilla = {v = 1, vanilla = 1, mc = 1, minecraft = 1}
if mod == '' or vanilla[mw.ustring.lower(parts.mod)] then
return prefix .. name
else
return prefix .. '[[' .. page .. name .. '|' .. name .. ']]'
end
end
 
function p.table( f )
local args = f
if multirow then
head = ''
elseif head ~= '' then multirow = 1 f:callParserFunction( '#dplvar:set', 'multirow', '1' ) else head = 1 end
-- Заканчивать таблицу при необходимости
local foot = args["подвал"] or ''
local name = ''
local description = ''
local effect = '' local duration = '' if args["название"] or args["показатьимя"] == '1' or multirow and args["показатьимя"] ~= '0' then
name = 'Название !! '
f:callParserFunction( '#dplvar:set', 'brewingname', '1' )
'! ' .. name .. 'width="150" | Ингредиенты !! ' .. recipeClass .. ' Схема [[Зельеварение|варки]]' .. effect .. duration .. 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 = 'Грубое зелье'
-- Ячейка с названием
local nameCell
if f:callParserFunction( '#dplvar', 'smeltingname' ) == '1' then if args["название"] or '' ~= '' then nameCell = args["название"] elseif multirow or f:callParserFunction( '#dplvar', 'brewingname' ) == '1' then else local names = {} local links = {} for v in mw.text.gsplit( args[2] or args["Выход"] or '', '%s*;%s*' ) do parts = getParts( v, args["Мод"] ) if not names[( parts.mod = or '' ) .. parts.mod or name] then local link = '' if not names[parts.mod then link = parts.mod .. ':/' .. parts.name] .. '|' end if parts.name:find( '^Люб' ) then table.insert( links, prefixedLinkmw.ustring.sub( parts.name, 0, 6 ) .. '[[' .. link .. mw.ustring.sub( parts.mod name, 6 ) .. ']]' ) else namestable.insert( links, '[[parts' .mod .. ':' link .. parts.name.. ']] = 1' )
end
names[( parts.mod or '' ) .. parts.name] = 1
end
 
nameCell = table.concat( links, '&nbsp;или<br>' )
end
nameCell = table.concat( links, '&nbsp;или<br>' )
end
if nameCell and args["запланированное"] then
nameCell = nameCell .. '<br>(' .. args["запланированное"] .. ')'
if args["ингредиенты"] or '' ~= '' and fuelslot ~= '' then
ingredientsCell = args["ингредиенты"] .. ' +<br>[[Огненный порошок]] (топливо)'
elseif 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
local mod = ( ingredients[v] or animatedIngredients[v] ).mod
local name = ( ingredients[v] or animatedIngredients[v] ).name
table.insert( ingredientsCell, prefixedLink( name, mod ) .. separator )
end
 
ingredientsCell = table.concat( ingredientsCell, '<br>\n' )
end
if fuelslot ~= '' then ingredientsCell = table.concat( ingredientsCell ) .. '&nbsp;+<br>\n[[Огненный порошок]] (топливо)' else ingredientsCell = table.concat( ingredientsCell ) end 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] ingredientsCell newArgs["Выход3"] = table.concat( ingredientsCell )args[4]
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назв"] newArgs.fuelslot = fuelslot
-- Ячейка с рецептом
local recipeCell = require( 'Модуль:Интерфейс' ).brewingStand( newArgs )
local row = {
'\n' .. ingredientsCell, 'style="padding:1px" |\n' .. recipeCell } if nameCell then table.insert( row, 1, nameCell ) end
-- Ячейка с эффектом
end
local title = mw.title.getCurrentTitle()
local title = mw.title.getCurrentTitle()
local category = ''
if args["запланированное"] and args["некат"] ~= '1' and title.namespace == 0 and not title.isSubpage then category = {} if args["запланированное"] then table.insert( categories, '[[Категория:Запланированные материалы]]' ) end if args["тип"Запланированное] then table.insert( categories, '[[Категория:Рецепты/' .. args["тип"] .. ']]' ) end if args["игнорировать"] ~= '1' then local dyes = { 'Оранжевый краситель', 'Сиреневый краситель', 'Светло-синий краситель', 'Жёлтый краситель', 'Лаймовый краситель', 'Розовый краситель', 'Серый краситель', 'Светло-серый краситель', 'Бирюзовый краситель', 'Фиолетовый краситель', 'Лазурит', 'Какао-бобы', 'Кактусовая зелень', 'Красный краситель', 'Чернильный мешок' } -- Названия в следующем списке должны писаться ОБЯЗАТЕЛЬНО со строчной буквы, так как встречаются в середине названия: local variants = { 'древесина', 'доски', 'окрашенное стекло', 'окрашенная стеклянная панель', 'шерсть', 'песчаник', 'ступени', 'плита', 'нажимная пластина', 'звёздочка', 'каменный кирпич', 'андезит', 'диорит', 'гранит', 'щит' }  for k, v in ipairs( ingredientKeys ) do v = mw.ustring.sub(v, 2 ) if not mw.ustring.find(v, ':' ) then if v == 'Любой краситель' or v == 'Любой цветной краситель' then if v == 'Любой краситель' then table.insert( dyes, 1, 'Костная мука' ) end else if v == 'Липкий поршень' then v = 'Поршень' elseif v == 'Любой гриб' or v == 'Красный гриб' or v == 'Коричневый гриб' then v = 'Гриб' elseif v == 'Красный песок' then v = 'Песок' elseif v == 'Древесный уголь' then v = 'Уголь' elseif mw.ustring.find(v, 'красный песчаник$' ) then v = 'Песчаник' elseif mw.ustring.find(v, '^Флаг ') or mw.ustring.find(v, ' флаг$') then v = 'Флаг' elseif v == 'Кварцевый пилон' or v == 'Резной кварцевый блок' then v = 'Кварцевый блок' else -- Объединить категории вариантов, описываемых на единой странице for _, variant in pairs( variants ) do if mw.ustring.find(v, ' ' .. variant .. '$' ) then v = variant break end end -- Убрать приставки for _, prefix in pairs( prefixes ) do if mw.ustring.find(v, '^' .. prefix .. ' ' ) then v = mw.ustring.gsub(v, '^' .. prefix .. ' ', '' ) break end end end end end end end   if args["отладка"] == '1' then return '<pre>' .. header .. '\n' .. row .. '\n|-\n' .. footer .. category .. '</pre>' else return header .. '\n' .. row .. '\n|-\n' .. footer .. category end
end
return header .. '\n' .. row .. '\n|-\n' .. footer .. category
end
return p
1136
правок

Навигация