Warning.png

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

Изменения

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

Модуль:Обжиг

4038 байтов добавлено, 19:23, 14 октября 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 f == mw.getCurrentFrame() then
args = frequire( 'Модуль:getParentProcessArgs' ).merge().args
else
f = mw.getCurrentFrame()
end
local getParts = require( 'Модуль:Инвентарный слот' ).getParts
-- Начинать таблицу при необходимости
if multirow then
head = ''
elseif head ~= '' then multirow = 1 f:callParserFunction( '#dplvar:set', 'multirow', '1' ) else head = 1 end
-- Заканчивать таблицу при необходимости
local foot = args["подвал"] or ''
recipeClass = 'class="unsortable" |'
end
local process = ' Процесс' if args["Прогресс"] and args["Мод"] then process=' Процесс' end
header = table.concat( {
' {| style="text-align:center" class="wikitable ' .. class .. '" data-description="Процесс"',
'! ' .. 'Ингредиенты !! ' .. recipeClass .. process .. name .. description,
'|-'
}, '\n' )
end
if fuel == '' and (args["Мод"] == 'IndustrialCraft 2' or 'GregTech' and args['Расход'] == 'Электричество') then
fuel = 'Энергия'
elseif fuel == '' then fuel = 'v:Любое топливо,1' end
-- Ячейка с названием
local nameCell
if f:callParserFunction( '#dplvar', 'craftingname' ) == '1' then
if args["название"] or '' ~= '' then
nameCell = args["название"]
elseif multirow or f:callParserFunction( '#dplvar', 'smeltingname' ) == '1' thenelse
local names = {}
local links = {}
parts = getParts( v, args["Мод"] )
if not names[( parts.mod or '' ) .. parts.name] and output ~= '' then
local link = '' if parts.mod then link = parts.mod .. '/' .. parts.name .. '|' end if parts.name:find( '^Люб' ) then if parts.mod then link = parts.mod .. '/' .. mw.ustring.gsub( mw.ustring.sub( parts.name, 7 ), "^%l", mw.ustring.upper ) .. '|' end table.insert( links, mw.ustring.subprefixedLink( parts.name, 0, 6 ) .. '[[' .. link .. mw.ustring.sub( parts.name, 6 mod ) .. ']]' ) elseif names[parts.mod == '' then link = parts.name table.insert( links, link ) end names[( parts.mod or ':' ) .. parts.name] = 1
end
end
nameCell = table.concat( links, '&nbsp;или<br>' )
end
end if nameCell and args["запланированное"] then nameCell = nameCell .. '<br>(' .. args["запланированное"] .. ')'end  -- Создать список ингредиентов local ingredients = {} local ingredientKeys = {} local animatedIngredients = {} local animatedKeys = {} for k, v in pairs( args ) do v = mw.text.trim( v ) if v ~= '' and mw.ustring.find(tostring( k ), '^%u?%d%d?$' ) then if mw.ustring.find(v, ';' ) then table.insert( animatedKeys, v ) else local parts = getParts( v, args["Мод"] ) parts.mod = parts.mod or '' local fullName = parts.mod .. ':' .. parts.name if not ingredients[fullName] then table.insert( ingredientKeys, fullName ) ingredients[fullName] = { mod = parts.mod, name = parts.name } end end end end for k, v in ipairs( animatedKeys ) do local frames = mw.text.split( v, '%s*;%s*' ) local length = #frames for k2, v2 in ipairs( frames ) do local parts = getParts( v2, args["Мод"] ) parts.mod = parts.mod or '' local fullName = parts.mod .. ':' .. parts.name if v2 ~= '' and not ingredients[fullName] and not animatedIngredients[fullName] then table.insert( ingredientKeys, fullName ) animatedIngredients[fullName] = { mod = parts.mod, name = parts.name, final = k2 == length } end end
end
-- Ячейка с ингредиентами
local ingredientsCell
else
ingredientsCell = {}
local ingredients = {}
for k, v in ipairs{ input, fuel } do
local separator = '&nbsp;+'
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, argselseif animatedIngredients["Мод"v] ) if parts.name ~= '' and not ingredientsanimatedIngredients[partsv].name] and ( k == 2 or k == 1 and v ~= fuel ) final 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 if parts.mod then link = parts.mod .. '/' .. mw.ustring.gsub( mw.ustring.sub( parts.name, 7 ), "^%l", mw.ustring.upper ) .. '|' end 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
ingredientsCell = table.concat( ingredientsCell ) end
-- Остальные аргументы
local newArgs = {
["Ресурс"] = args[1] or args["Ресурс"], ["Выход"] = args[2] or args["Выход"], ["Топливо"] = fuel, ["РНазв"] = args["рНазв"], ["ВНазв"] = args["вНазв"], ["ТНазв"] = args["тНазв"], ["Мод"] = args["Мод"], ["Прогресс"] = args["Прогресс"], ["Расход"] = args["Расход"] }
-- Ячейка с рецептом
local recipeCell = require( 'Модуль:Интерфейс' ).furnace( newArgs )
local row = {
'|\n' .. ingredientsCell, 'style="padding:1px" |\n' .. recipeCell } if nameCell then table.insert( row, 3, '<b>' .. nameCell .. '</b>' ) end if f:callParserFunction( '#dplvar', 'smeltingdescription' ) == '1' then table.insert( row, args["описание"] or '' )endrow = table.concat( row, '\n|' ) local footer = ''if foot ~= '' then footer = '|}' f:callParserFunction( '#dplvar:set', 'smeltingname', '0', 'smeltingdescription', '0' )end  -- Создание различных категорий для DPL local title = mw.title.getCurrentTitle() local categories = '' if args["некат"] ~= '1' and title.namespace == 0 and not title.isSubpage then categories = {} 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
row = table.concat( row, '\n|' )
local footer if args["отладка"] = '' if foot ~= '1' then footer = return '|}<pre>' f:callParserFunction( .. header .. '#dplvar:set\n', .. row .. 'smeltingname\n|-\n', '0', 'smeltingdescription.. footer .. categories .. ', </pre>'0' ) endelse local title = mw return header .title.getCurrentTitle() local category = '\n' if args["запланированное"] and args["некат"] ~= .. row .. '1\n|-\n' and title.namespace == 0 and not title.isSubpage then category = '[[Категория:Запланированное]]'footer .. categories
end
end  return header .. '\n' .. row .. '\n|-\n' .. footer .. category
end
return p
1136
правок

Навигация