Minecraft Wiki
Нет описания правки
Нет описания правки
Строка 42: Строка 42:
   
 
function p.procTable( f )
 
function p.procTable( f )
local args = require( 'Module:ProcessArgs' ).merge( true )
+
local args = f
  +
if f == mw.getCurrentFrame() then
  +
args = f:getParent().args
  +
else
  +
f = mw.getCurrentFrame()
  +
end
   
 
-- Чтение и генерация аргументов
 
-- Чтение и генерация аргументов

Версия от 11:27, 25 марта 2020

Этот модуль реализует шаблон {{GTOreProc6}}.

Зависимости

Смотрите также

local slot = require('Модуль:Инвентарный слот').slot
local GTCell = require('Модуль:Обработка').interface
local CraftCell = require('Модуль:Интерфейс').craftingTable
-- Первая строчная буква
local lcfirst = function(s)
	local s1 = mw.ustring.sub(s,1,1)
	s1 = mw.ustring.lower(s1)
	local s2 = mw.ustring.sub(s,2)
	s = s1 .. s2
	return s
end
-- Предмет для строки-заголовка
local addSlot = function( item, mod)
	return slot{
		[1] = item, ["мод"] = mod, ["класс"] = 'invslot-plain', ["масштаб"] = '0.5'
	}
end
-- Строка-заголовок
local addHeadLine = function(body, block, text, mod)
	local head = body:tag('tr')
	local head_1 = head:tag('th')
	head_1:attr( 'colspan', '2' )
	head_1:wikitext("'''" .. addSlot(block, mod) .. text .. "'''")
end
-- Ячейка с машиной
local addGTCell = function( line, progress, args )
	local cell = line:tag('td')
	cell:css('padding','1px')
	args["Прогресс"] = progress
	args["Мод"] = "GregTech"
	cell:wikitext(GTCell(args))
end
-- Ячейка с верстаком
local addCraftCell = function( line, args, mod )
	local cell = line:tag('td')
	cell:css('padding','1px')
	cell:wikitext(CraftCell(args))
end

-- Экспортируемые функции
local p = {}

function p.procTable( f )
	local args = f
	if f == mw.getCurrentFrame() then
		args = f:getParent().args
	else
		f = mw.getCurrentFrame()
	end

-- Чтение и генерация аргументов
	local mod = args["МодБ"] or 'GregTech'
	local out = args["Выход"] or '2'
	local SDust = '[Пыль породы]Каменная пыль'
	local main_res = mw.loadData('Модуль:Обработка/Материалы/' .. args["Руда"])
	if main_res['nugget'] ~= '-' then
		local nugget = main_res['nugget']
	end
	if main_res['Плавление'] ~= '-' then
		local temp = main_res['Плавление']
	end
	if main_res['gem'] ~= '-' then
		local gem = main_res['gem']
	elseif main_res['rock'] ~= '-' then
		local rock = main_res['rock']
	end
	if main_res['Кальцит'] ~= 0 then
		local calcite = main_res['Кальцит']
	end
	local ore = main_res['ore']
	local block = args["РудаБ"] or main_res['ore']
	local sand = main_res['ore:sand']
	local crushed = main_res['crushed']
	local purified = main_res['purified']
	local refined = main_res['refined']
	local dust = main_res['dust']
	local tinycrushed = main_res['tiny crushed']
	local tinypurified = main_res['tiny purified']
	local tinyrefined = main_res['tiny refined']
	local tinydust = main_res['tiny']
	local micro = main_res['micro']
	local impure = main_res['impure']
	local pure = main_res['pure']
	
-- таблица побочных продуктов. Общая и для промывочного шлюза.
	local ByProd = {}
	local ByProdSluice = {}
	local bk = 1
	local ByProdK = main_res['Побочных']
	for i=1,ByProdK do
		table.insert(ByProd,mw.loadData('Модуль:Обработка/Материалы/' .. main_res["Побочный" .. i]))
		table.insert(ByProdSluice,mw.loadData('Модуль:Обработка/Материалы/' .. main_res["Побочный" .. i]))
	end
	local nuggets = {}
	for i=1,ByProdK do
		if ByProd[i]['nugget'] then
			nuggets[i] = ByProd[i]['nugget']
		end
		if ByProd[i]['Ртуть'] == 1 then
			local mercury = ByProd[i]
		end
		if ByProd[i]['Персульфат'] == 1 then
			local SPersulphate = ByProd[i]
		end
	end
	if ByProdK < 3 then
		if ByProdK == 0 then
			ByProd[1] = main_res
		end
		if ByProdK < 2 then
			ByProd[2] = ByProd[1]
		end
		ByProd[3] = ByProd[2]
	end
-- заполнение таблицы для промывочного шлюза
	local k = 0
	local st = ''
	local tinyore = {}
	if table.maxn(ByProdSluice) ~= 0 then
		for i=1,8 do
			if not ByProdSluice[i] then
				k = k + 1
				ByProdSluice[i] = ByProdSluice[k]
			end
			table.insert(tinyore, ByProdSluice[i]['tiny purified'])
		end
	else
		for i=1,8 do
			table.insert(tinyore, main_res[i]['tiny purified'])
		end
	end
-- создание крошечных производных
	local tiny = {}
	local bpDust = {}
	local tinyrefore = {}
	st = ''
	local N
	if ByProdK < 4 then
		N = 3
	else
		N = ByProdK
	end
	for i=1,N do
		table.insert(tiny,ByProd[i]['tiny'])
		table.insert(bpDust,ByProd[i]['dust'])
		if i < 4 then
			table.insert(tinyrefore, ByProd[i]['tiny refined'])
		end
	end

--Построение таблицы	
	local body = mw.html.create('table'):addClass('wikitable')
	body:css('text-align' , 'center')
----------- блок руды
	body:wikitext(addHeadLine(body, block .. ';' .. sand, 'Блок руды', mod))
-- строка 1
	local line_1_1 = body:tag('tr')
	line_1_1:wikitext(addGTCell(line_1_1, 'Дробитель:gt6', {["Ресурс1"] = block, ["Выход1"] = crushed .. ',' .. out/2, ["Выход2"] = crushed .. ',' .. out/2, ["Выход3"] = SDust}))
	line_1_1:wikitext(addGTCell(line_1_1, 'Просеиватель:gt6', {["Ресурс1"] = sand, ["Выход1"] = purified, ["Выход2"] = tiny[1], ["Выход3"] = tiny[2], ["Выход4"] = tiny[3]}))
-- 
	local line_1_2 = body:tag('tr')
	local SluiceArgs = {}
	SluiceArgs["Выход1"] = dust
	if ByProdK > 0 then
		for i=1,ByProdK do
			SluiceArgs["Выход" .. i + 1] = bpDust[i]
		end
	end
	SluiceArgs["Ресурс1"] = block
	SluiceArgs["Ресурс2"] = impure
	SluiceArgs["Ресурс3"] = pure
	SluiceArgs["Ресурс4"] = crushed
	SluiceArgs["Ресурс5"] = purified
	SluiceArgs["Ресурс6"] = refined
	line_1_2:wikitext(addGTCell(line_1_2, 'Список продуктов:gt6', SluiceArgs))
	line_1_2:wikitext('<td>&nbsp;</td>')
----------- измельчённая руда
	body:wikitext(addHeadLine(body, crushed, 'Измельчённая руда', 'GregTech'))
-- строка 1
	local line_2_1 = body:tag('tr')
	line_2_1:wikitext(addGTCell(line_2_1, 'Измельчитель:gt6', {["Ресурс1"] = crushed .. ';' .. tinycrushed, ["Выход1"] = dust .. ';' .. micro .. ',9', ["Выход2"] = micro .. ',9;'}))
	line_2_1:wikitext(addGTCell(line_2_1, 'Дробитель:ic2', {["Ресурс1"] = crushed .. ';' .. tinycrushed, ["Выход1"] = dust .. ';' .. tinydust}))
-- строка 2
	local line_2_2 = body:tag('tr')
	local CrushedArgs = {}
	local Washed = {}
	local Washed_low_num = {}
	for i=1,ByProdK do
		Washed[i] = {}
		table.insert(Washed[i], tiny[i])
		table.insert(Washed[i], tinyore[i])
		table.insert(Washed[i], nuggets[i])	
		table.insert(Washed_low_num, tiny[i])
		table.insert(Washed_low_num, tinyore[i])
		table.insert(Washed_low_num, nuggets[i])	
	end
	local washed_num = table.maxn(Washed_low_num)
	local chance
	chance = math.floor( 100 * 100 / ( washed_num * 2 ) ) / 100
	if washed_num > 11 then
		for i=1,ByProdK do
			CrushedArgs["Выход" .. i + 1] = table.concat(Washed[i],';')
			CrushedArgs["Шанс" .. i + 1] = 'для каждой единицы ' .. chance
		end
	else
		if washed_num > 8 then
			CrushedArgs["Машина"] = '11341100100,Cauldron'
		end
		for i=1,washed_num do
			CrushedArgs["Выход" .. i + 1] = Washed_low_num[i]
			CrushedArgs["Шанс" .. i + 1] = chance
		end
	end
	CrushedArgs["Ресурс1"] = crushed
	CrushedArgs["Выход1"] = purified
	CrushedArgs["РесурсЖ1"] = 'Вода'
	CrushedArgs["РЖК1"] = '333'
	line_2_2:wikitext(addGTCell(line_2_2, 'Котёл:gt6', CrushedArgs))
	line_2_2:wikitext(addGTCell(line_2_2, 'Термальная центрифуга:ic2', {["Ресурс1"] = crushed .. ';' .. tinycrushed .. ',9', ["Выход1"] = refined, ["Выход2"] = tinyrefore[2], ["Выход3"] = 'Каменная пыль'}))
-- строка 3
	local line_2_3 = body:tag('tr')
	for i=1,8 do
		SluiceArgs["Выход" .. i + 1] = tinyore[i] .. ',9;' .. tinyore[i]
		SluiceArgs["Шанс" .. i + 1] = 'для каждой единицы 3;3'
	end
	SluiceArgs["Ресурс1"] = crushed .. ';' .. tinycrushed
	SluiceArgs["Выход1"] = purified .. ';' .. tinypurified
	SluiceArgs["РесурсЖ1"] = 'Вода'
	SluiceArgs["РЖК1"] = '900;100'
	SluiceArgs["ВыходЖ1"] = 'Шлам'
	SluiceArgs["ВЖК1"] = '900;100'
	line_2_3:wikitext(addGTCell(line_2_3, 'Промывочный шлюз:gt6', SluiceArgs))
	line_2_3:wikitext(addGTCell(line_2_3, 'Рудопромывочная машина:ic2', {["Ресурс1"] = crushed .. ';' .. tinycrushed .. ',9',  ["Выход1"] = purified, ["Выход2"] = tinyore[1] .. ',2', ["Выход3"] = 'Каменная пыль'}))
----------- очищенная руда
	body:wikitext(addHeadLine(body, purified, 'Очищенная руда', 'GregTech'))
-- строка 1
	local line_3_1 = body:tag('tr')
	line_3_1:wikitext(addGTCell(line_3_1, 'Измельчитель:gt6', {["Ресурс1"] = purified .. ';' .. tinypurified, ["Выход1"] = dust .. ';' .. micro .. ',10', ["Выход2"] = micro .. ',18;'}))
	line_3_1:wikitext(addGTCell(line_3_1, 'Дробитель:ic2', {["Ресурс1"] = purified .. ';' .. tinypurified, ["Выход1"] = dust .. ';' .. tinydust}))
-- строка 2
	local line_3_2 = body:tag('tr')
	line_3_2:wikitext(addGTCell(line_3_2, 'Центрифуга:gt6', {["Ресурс1"] = purified .. ';' .. tinypurified .. ',9', ["Выход1"] = dust .. ';' .. tinydust .. ',9', ["Выход2"] = tinyrefore[1], ["Выход3"] = tinyrefore[2], ["Выход4"] = tinyrefore[3]}))
	line_3_2:wikitext(addGTCell(line_3_2, 'Термальная центрифуга:ic2', {["Ресурс1"] = purified .. ';' .. tinypurified .. ',9', ["Выход1"] = refined, ["Выход2"] = tinyrefore[2]}))
----------- рафинированная руда
	body:wikitext(addHeadLine(body, refined, 'Рафинированная руда', 'GregTech'))
-- строка 1
	local line_4_1 = body:tag('tr')
	line_4_1:wikitext(addGTCell(line_4_1, 'Измельчитель:gt6', {["Ресурс1"] = refined .. ';' .. tinyrefined, ["Выход1"] = dust .. ';' .. micro .. ',11', ["Выход2"] = micro .. ',27;'}))
	line_4_1:wikitext(addGTCell(line_4_1, 'Дробитель:ic2', {["Ресурс1"] = refined .. ';' .. tinyrefined, ["Выход1"] = tinydust .. ',11;' .. tinydust}))
----------- загрязнённая пыль
	body:wikitext(addHeadLine(body, impure, 'Загрязнённая пыль', 'GregTech'))
-- строка 1
	local line_5_1 = body:tag('tr')
	line_5_1:wikitext(addGTCell(line_5_1, 'Центрифуга:gt6', {["Ресурс1"] = impure, ["Выход1"] = dust, ["Выход2"] = tiny[1]}))
	line_5_1:wikitext(addGTCell(line_5_1, 'Электролизёр:gt6', {["Ресурс1"] = 'Переключатель варианта 0', ["Ресурс2"] = impure, ["Выход1"] = dust, ["Выход2"] = tiny[2]}))
-- строка 2
	local line_5_2 = body:tag('tr')
	chance = math.floor( 100 * 100 * 2 / ( 3 * ByProdK ) ) / 100
	local NextArgs = {}
	if ByProdK == 0 then
		ByProdK = 1
	end
	for i=1,ByProdK do
		NextArgs["Выход" .. i + 1] = tiny[i]
		NextArgs["Шанс" .. i + 1] = chance
	end
	NextArgs["Ресурс1"] = impure
	NextArgs["Выход1"] = dust
	NextArgs["РесурсЖ1"] = 'Вода'
	NextArgs["РЖК1"] = '333'
	line_5_2:wikitext(addGTCell(line_5_2, 'Котёл:gt6', NextArgs))
----------- очищенная пыль
	body:wikitext(addHeadLine(body, pure, 'Очищенная пыль', 'GregTech'))
-- строка 1
	local line_6_1 = body:tag('tr')
	line_6_1:wikitext(addGTCell(line_6_1, 'Центрифуга:gt6', {["Ресурс1"] = pure, ["Выход1"] = dust, ["Выход2"] = tiny[2]}))
	line_6_1:wikitext(addGTCell(line_6_1, 'Электролизёр:gt6', {["Ресурс1"] = 'Переключатель варианта 0', ["Ресурс2"] = pure, ["Выход1"] = dust, ["Выход2"] = tiny[3]}))
-- строка 2
	local line_6_2 = body:tag('tr')
	chance = math.floor( 100 * 100 * 3 / ( 4 * ByProdK ) ) / 100
	for i=1,ByProdK do
		NextArgs["Выход" .. i + 1] = tiny[i]
		NextArgs["Шанс" .. i + 1] = chance
	end
	NextArgs["Ресурс1"] = pure
	line_6_2:wikitext(addGTCell(line_6_2, 'Котёл:gt6', NextArgs))
----------- конец таблицы
	return tostring( mw.html.create( 'table' ):node( body ) )
end

return p