BloodCaster (обс. | вклад) Нет описания правки |
BloodCaster (обс. | вклад) Нет описания правки |
||
Строка 4: | Строка 4: | ||
-- Функция добавления слота |
-- Функция добавления слота |
||
− | local addSlot = function( |
+ | local addSlot = function(args, version, mod, item, CSS, class, prefix, default) |
prefix = prefix or item |
prefix = prefix or item |
||
return slot{ |
return slot{ |
||
Строка 18: | Строка 18: | ||
-- Конструктор текста с подсказкой |
-- Конструктор текста с подсказкой |
||
− | local help_string = function ( |
+ | local help_string = function (HBody, HTitle, HText) |
HBody:css('border-bottom','1px dotted') |
HBody:css('border-bottom','1px dotted') |
||
HBody:css('cursor','help') |
HBody:css('cursor','help') |
||
Строка 27: | Строка 27: | ||
-- Контейнер интерфейса |
-- Контейнер интерфейса |
||
− | + | local body = mw.html.create('div') |
|
− | + | local recipe = body:tag('span'):addClass('gui-recipe') |
|
-- Высота шаблона |
-- Высота шаблона |
||
− | + | local h_size = 140 |
|
-- Экспортируемые функции |
-- Экспортируемые функции |
||
local p = {} |
local p = {} |
||
− | p.interface = function( |
+ | p.interface = function(f) |
+ | |||
− | local args = f |
||
+ | local args = f |
||
− | if f == mw.getCurrentFrame() then |
||
+ | if f == mw.getCurrentFrame() then |
||
− | args = f:getParent().args |
||
+ | args = f:getParent().args |
||
− | else |
||
+ | else |
||
− | f = mw.getCurrentFrame() |
||
+ | f = mw.getCurrentFrame() |
||
− | end |
||
+ | end |
||
− | |||
+ | |||
-- Параметры машины |
-- Параметры машины |
||
− | + | local machine_list = mw.loadData('Модуль:ТестОбработка/Машины') |
|
− | + | local versions = { |
|
− | + | ["GregTech 4"] = 'GregTech 4', |
|
− | + | ["gt4"] = 'GregTech 4', |
|
− | + | ["GT4"] = 'GregTech 4', |
|
− | + | ["GregTech 5"] = 'GregTech 5', |
|
− | + | ["gt5"] = 'GregTech 5', |
|
− | + | ["GT5"] = 'GregTech 5', |
|
− | + | ["GregTech 5 Unofficial"] = 'GregTech 5 Unofficial', |
|
− | + | ["gt5u"] = 'GregTech 5 Unofficial', |
|
− | + | ["GT5U"] = 'GregTech 5 Unofficial', |
|
− | + | ["GregTech 6"] = 'GregTech 6', |
|
− | + | ["gt6"] = 'GregTech 6', |
|
− | + | ["GT6"] = 'GregTech 6', |
|
− | + | ["IndustrialCraft 2"] = 'IndustrialCraft 2', |
|
− | + | ["ic2"] = 'IndustrialCraft 2', |
|
− | + | ["IC2"] = 'IndustrialCraft 2', |
|
− | + | ["Оригинальная игра"] = 'Оригинальная игра', |
|
− | + | '&4Неизвестна', |
|
− | + | } |
|
− | + | local version |
|
− | + | local progress = args["Прогресс"] or '' |
|
− | + | local mod |
|
+ | |||
− | |||
− | + | if args["Мод"] ~= '' then |
|
− | + | mod = args["Мод"] |
|
− | + | end |
|
+ | |||
− | |||
− | + | if progress ~= '' then |
|
− | + | version = mw.ustring.match(progress, ':%s*([a-zA-Zа-яА-ЯёЁ 0-9]+)') or args["Версия"] or mod |
|
− | + | progress = mw.ustring.match(progress, '([a-zA-Zа-яА-ЯёЁ 0-9]+):') or progress or '&4Неизвестная машина' |
|
+ | else |
||
+ | version = args["Версия"] or 'Оригинальная игра' |
||
+ | progress = 'Печь' |
||
+ | end |
||
+ | |||
+ | if version then |
||
+ | if versions[version] then |
||
+ | version = versions[version] |
||
else |
else |
||
+ | version = versions[1] |
||
− | version = args["Версия"] or 'Оригинальная игра' |
||
− | progress = 'Печь' |
||
− | end |
||
− | |||
− | if version then |
||
− | if versions[version] then |
||
− | version = versions[version] |
||
− | else |
||
− | version = versions[1] |
||
− | end |
||
− | end |
||
− | |||
− | if version == "GregTech 4" or version == "IndustrialCraft 2" then |
||
− | mod = mod or version |
||
− | elseif version == "GregTech 6" or version == "GregTech 5" or version == "GregTech 5 Unofficial" then |
||
− | mod = mod or 'GregTech' |
||
− | else |
||
− | mod = mod or '' |
||
end |
end |
||
+ | end |
||
+ | |||
+ | if version == "GregTech 4" or version == "IndustrialCraft 2" then |
||
+ | mod = mod or version |
||
+ | elseif version == "GregTech 6" or version == "GregTech 5" or version == "GregTech 5 Unofficial" then |
||
+ | mod = mod or 'GregTech' |
||
+ | else |
||
+ | mod = mod or '' |
||
+ | end |
||
+ | |||
+ | machine_list = machine_list[version] |
||
+ | local machine = machine_list[progress] |
||
+ | local machine_code = args["Машина"] or machine[1] |
||
− | machine_list = machine_list[version] |
||
− | local machine = machine_list[progress] |
||
− | local machine_code = args["Машина"] or machine[1] |
||
− | |||
-- Строк ячеек ресурса |
-- Строк ячеек ресурса |
||
− | + | local input_rows = string.sub(machine_code,1,1) or '1' |
|
-- Столбцов ячеек ресурса |
-- Столбцов ячеек ресурса |
||
− | + | local input_cols = string.sub(machine_code,2,2) or '1' |
|
-- Строк ячеек выхода |
-- Строк ячеек выхода |
||
− | + | local output_rows = string.sub(machine_code,3,3) or '1' |
|
-- Столбцов ячеек выхода |
-- Столбцов ячеек выхода |
||
− | + | local output_cols = string.sub(machine_code,4,4) or '1' |
|
-- Строк ячеек жидкого ресурса |
-- Строк ячеек жидкого ресурса |
||
− | + | local fluid_input_rows = string.sub(machine_code,5,5) or '0' |
|
-- Столбцов ячеек жидкого ресурса |
-- Столбцов ячеек жидкого ресурса |
||
− | + | local fluid_input_cols = string.sub(machine_code,6,6) or '0' |
|
-- Строк ячеек жидкого выхода |
-- Строк ячеек жидкого выхода |
||
− | + | local fluid_output_rows = string.sub(machine_code,7,7) or '0' |
|
-- Столбцов ячеек жидкого выхода |
-- Столбцов ячеек жидкого выхода |
||
− | + | local fluid_output_cols = string.sub(machine_code,8,8) or '0' |
|
-- Оригинальное название |
-- Оригинальное название |
||
− | + | local OrigName = mw.ustring.match(machine_code, ',%s*([-/()a-zA-Z 0-9]+)') or '' |
|
-- Определитель стиля |
-- Определитель стиля |
||
− | + | local style = machine_list["Skin"] |
|
− | + | if machine["Skin"] then |
|
− | + | style = style .. '-' .. machine["Skin"] |
|
− | + | end |
|
+ | |||
+ | local class1 |
||
+ | local class2 |
||
+ | local large = 0 |
||
+ | if machine["Skin"] == 'bronze' then |
||
+ | class1 = 'bronze_invslot' |
||
+ | class2 = 'bronze_invslot' |
||
+ | elseif machine["Out_class"] then |
||
+ | class2 = 'invslot-large' |
||
+ | large = 8 |
||
+ | end |
||
− | local class1 |
||
− | local class2 |
||
− | local large = 0 |
||
− | if machine["Skin"] == 'bronze' then |
||
− | class1 = 'bronze_invslot' |
||
− | class2 = 'bronze_invslot' |
||
− | elseif machine["Out_class"] then |
||
− | class2 = 'invslot-large' |
||
− | large = 8 |
||
− | end |
||
− | |||
-- Иконка реакции |
-- Иконка реакции |
||
− | + | local fuelImg |
|
− | + | local input_pic = 0 |
|
− | + | if (machine_list["Image"] or machine["Image"]) and (input_rows + fluid_input_rows) > '1' then |
|
− | + | fuelImg = machine["Image"] or machine_list["Image"] |
|
− | + | input_pic = 1 |
|
− | + | elseif (args["Расход"] and mod ~= '') then |
|
− | + | fuelImg = '[[Файл:Grid layout ' .. args["Расход"] .. ' (' .. mod .. ').png|link=|alt=]]' |
|
− | + | end |
|
-- Предопределённые аргументы |
-- Предопределённые аргументы |
||
− | + | if machine_list["Def_args"] then |
|
− | + | for k,v in pairs(machine_list["Def_args"]) do |
|
− | + | args[k] = v |
|
− | end |
||
end |
end |
||
+ | end |
||
− | if machine and machine["Def_args"] then |
||
− | + | if machine and machine["Def_args"] then |
|
+ | for k,v in pairs(machine["Def_args"]) do |
||
− | args[k] = v |
||
+ | args[k] = v |
||
− | end |
||
end |
end |
||
+ | end |
||
-- Определители отступов |
-- Определители отступов |
||
− | + | local input_size = 0 |
|
− | + | local v_margin_input_1 = 0 |
|
− | + | local v_margin_input_2 = 0 |
|
− | + | local output_size = 0 |
|
− | + | local v_margin_output_1 = 0 |
|
− | + | local v_margin_output_2 = 0 |
|
-- Переопределение количества получаемых предметов (1-4) |
-- Переопределение количества получаемых предметов (1-4) |
||
− | + | if args["Уровень"] then |
|
− | + | output_rows = tostring(math.floor (args["Уровень"] / 4) + 1) |
|
− | + | output_cols = tostring(args["Уровень"] / output_rows) |
|
− | + | end |
|
-- Предопределение или конвертация некоторых аргументов |
-- Предопределение или конвертация некоторых аргументов |
||
− | + | args["Шанс1"] = args["Шанс1"] or args["Шанс"] |
|
− | + | args["Ресурс1"] = args["Ресурс1"] or args["Ресурс"] or args[1] |
|
− | + | args["Ресурс2"] = args["Ресурс2"] or args["Топливо"] or args["топливо"] |
|
− | + | args["Выход1"] = args["Выход1"] or args["Выход"] or args[2] |
|
− | + | args["РесурсЖ1"] = args["РесурсЖ1"] or args["РесурсЖ"] |
|
− | + | args["РЖК1"] = args["РЖК1"] or args["РЖК"] |
|
− | + | args["РЖТ1"] = args["РЖТ1"] or args["РЖТ"] |
|
− | + | args["ВыходЖ1"] = args["ВыходЖ1"] or args["ВыходЖ"] |
|
− | + | args["ВЖК1"] = args["ВЖК1"] or args["ВЖК"] |
|
− | + | args["ВЖТ1"] = args["ВЖТ1"] or args["ВЖТ"] |
|
− | + | if progress == 'Просеиватель' and version == 'GregTech 6' and args["Выход7"] then |
|
− | + | args["Шанс1"] = '0.01' |
|
− | + | args["Шанс2"] = '01' |
|
− | + | args["Шанс3"] = '04' |
|
− | + | args["Шанс4"] = '15' |
|
− | + | args["Шанс5"] = '20' |
|
− | + | args["Шанс6"] = '40' |
|
− | + | args["Шанс7"] = '50' |
|
− | + | end |
|
-- Реорганизация интерфейса некоторых машин |
-- Реорганизация интерфейса некоторых машин |
||
− | + | if args["ОднаСтрока"] |
|
− | + | then |
|
− | + | input_rows = '0' |
|
− | + | fluid_input_cols = '2' |
|
− | + | args["РесурсЖ2"] = args["Ресурс1"] |
|
− | + | end |
|
+ | |||
− | |||
-- Параметры стрелки прогресса |
-- Параметры стрелки прогресса |
||
− | + | local ArrowIds = mw.loadData('Модуль:Обработка/Стрелки') |
|
− | + | local param = {} |
|
− | + | if ArrowIds[version] and ArrowIds[version]['Параметры'] then |
|
− | + | param = ArrowIds[version]['Параметры'] |
|
+ | else |
||
+ | param = { |
||
+ | ["формат"] = 280, |
||
+ | ["масштаб"] = 1, |
||
+ | ["поз"] = 1, |
||
+ | ["верт_разм"] = 48, |
||
+ | ["разм"] = 56, |
||
+ | } |
||
+ | end |
||
+ | local ArrowID = 1 |
||
+ | local arrow_version = version |
||
+ | local arrowtext = '&3' .. progress |
||
+ | if OrigName and OrigName ~= '' then |
||
+ | arrowtext = arrowtext .. '/&9' .. OrigName |
||
+ | end |
||
+ | if version ~= 'Оригинальная игра' then |
||
+ | arrowtext = arrowtext .. '//&7Модификация:/' |
||
+ | end |
||
+ | if version ~= '&4Неизвестна' and version ~= 'Оригинальная игра' then |
||
+ | if ArrowIds[version] and ArrowIds[version][progress] then |
||
+ | ArrowID = ArrowIds[version][progress] |
||
else |
else |
||
+ | arrowtext = arrowtext .. ' &4(Нет стрелки)' |
||
− | param = { |
||
− | ["формат"] = 280, |
||
− | ["масштаб"] = 1, |
||
− | ["поз"] = 1, |
||
− | ["верт_разм"] = 48, |
||
− | ["разм"] = 56, |
||
− | } |
||
end |
end |
||
+ | else |
||
− | local ArrowID = 1 |
||
− | + | arrow_version = 'GregTech 4' |
|
+ | end |
||
− | local arrowtext = '&3' .. progress |
||
− | + | if version == 'GregTech 5 Unofficial' then |
|
+ | arrow_version = 'GregTech 5' |
||
− | arrowtext = arrowtext .. '/&9' .. OrigName |
||
− | + | end |
|
+ | local size = param["разм"] -- ширина спрайта в пикселях |
||
− | if version ~= 'Оригинальная игра' then |
||
+ | local v_size = param["верт_разм"] -- высота спрайта в пикселях |
||
− | arrowtext = arrowtext .. '//&7Модификация:/' |
||
+ | local pos = ArrowID - 1 -- положение спрайта в таблице |
||
− | end |
||
+ | local sheetWidth = param["формат"] -- ширина таблицы спрайта в пикселях |
||
− | if version ~= '&4Неизвестна' and version ~= 'Оригинальная игра' then |
||
+ | local tiles = sheetWidth / size -- количество спрайтов в одной строке |
||
− | if ArrowIds[version] and ArrowIds[version][progress] then |
||
+ | local left = pos % tiles * size -- горизонтальная координата спрайта |
||
− | ArrowID = ArrowIds[version][progress] |
||
+ | local top = math.floor(pos / tiles) * v_size -- вертикальная координата спрайта |
||
− | else |
||
+ | local scale = param["масштаб"] -- масштаб спрайта (во сколько раз увеличить или уменьшить размер) |
||
− | arrowtext = arrowtext .. ' &4(Нет стрелки)' |
||
+ | local arrow_width = (args['ширина_стрелки'] or size) * scale -- ширина спрайта с учётом масштаба |
||
− | end |
||
+ | local arrow_height = (args['высота_стрелки'] or v_size) * scale -- высота спрайта с учётом масштаба |
||
− | else |
||
+ | |||
− | arrow_version = 'GregTech 4' |
||
− | end |
||
− | if version == 'GregTech 5 Unofficial' then |
||
− | arrow_version = 'GregTech 5' |
||
− | end |
||
− | local size = param["разм"] -- ширина спрайта в пикселях |
||
− | local v_size = param["верт_разм"] -- высота спрайта в пикселях |
||
− | local pos = ArrowID - 1 -- положение спрайта в таблице |
||
− | local sheetWidth = param["формат"] -- ширина таблицы спрайта в пикселях |
||
− | local tiles = sheetWidth / size -- количество спрайтов в одной строке |
||
− | local left = pos % tiles * size -- горизонтальная координата спрайта |
||
− | local top = math.floor(pos / tiles ) * v_size -- вертикальная координата спрайта |
||
− | local scale = param["масштаб"] -- масштаб спрайта (во сколько раз увеличить или уменьшить размер) |
||
− | local arrow_width = ( args['ширина_стрелки'] or size ) * scale -- ширина спрайта с учётом масштаба |
||
− | local arrow_height = ( args['высота_стрелки'] or v_size ) * scale -- высота спрайта с учётом масштаба |
||
− | |||
-- вычисление ширины зоны исходных ресурсов и разницы между количеством столбцов предметов и жидких ресурсов |
-- вычисление ширины зоны исходных ресурсов и разницы между количеством столбцов предметов и жидких ресурсов |
||
− | + | if input_cols >= fluid_input_cols |
|
− | + | then |
|
− | + | input_size = input_cols * 36 |
|
− | + | else |
|
− | + | input_size = fluid_input_cols * 36 |
|
− | + | end |
|
-- Горизонтальные отступы |
-- Горизонтальные отступы |
||
− | + | if output_cols >= fluid_output_cols |
|
− | + | then |
|
− | + | output_size = output_cols * 36 |
|
− | + | else |
|
− | + | output_size = fluid_output_cols * 36 |
|
− | + | end |
|
− | + | local h_margin = (282 - output_size - input_size - arrow_width) / 2 - large |
|
+ | |||
+ | if version == '&4Неизвестна' then |
||
+ | body:wikitext('[[Категория:Страницы с неизвестной версией машин]]') |
||
+ | end |
||
− | if version == '&4Неизвестна' then |
||
− | body:wikitext('[[Категория:Страницы с неизвестной версией машин]]') |
||
− | end |
||
− | |||
-- Расширение при большом количестве строк |
-- Расширение при большом количестве строк |
||
− | + | if (input_rows + fluid_input_rows) > 3 or (output_rows + fluid_output_rows) > 3 then |
|
− | + | h_size = h_size + 21 |
|
+ | recipe:css('height','161px') |
||
− | end |
||
+ | end |
||
-- центровка ячеек исходного ресурса |
-- центровка ячеек исходного ресурса |
||
− | + | if (input_rows == '0' or fluid_input_rows == '0') |
|
− | + | then |
|
− | + | if fluid_input_rows == '0' |
|
− | + | then |
|
− | + | v_margin_input_1 = (h_size - 36 * (input_rows + input_pic)) / 2 |
|
− | + | else |
|
− | + | v_margin_input_1 = (h_size - 36 * (fluid_input_rows)) / 2 |
|
− | end |
||
− | elseif input_pic ~= 0 then |
||
− | v_margin_input_1 = ( h_size - 36 * ( input_rows + input_pic + fluid_input_rows ) ) / 2 |
||
− | else |
||
− | v_margin_input_1 = math.ceil( ( h_size - 36 * ( input_rows + fluid_input_rows ) ) / 3 ) |
||
− | v_margin_input_2 = v_margin_input_1 |
||
end |
end |
||
+ | elseif input_pic ~= 0 then |
||
+ | v_margin_input_1 = (h_size - 36 * (input_rows + input_pic + fluid_input_rows)) / 2 |
||
+ | else |
||
+ | v_margin_input_1 = math.ceil((h_size - 36 * (input_rows + fluid_input_rows)) / 3) |
||
+ | v_margin_input_2 = v_margin_input_1 |
||
+ | end |
||
-- центровка ячеек получаемых материалов |
-- центровка ячеек получаемых материалов |
||
− | + | if (output_rows == '0' or fluid_output_rows == '0') |
|
− | + | then |
|
− | + | if fluid_output_rows == '0' |
|
− | + | then |
|
− | + | v_margin_output_1 = (h_size - 36 * (output_rows)) / 2 |
|
− | + | else |
|
− | + | v_margin_output_1 = (h_size - 36 * (fluid_output_rows)) / 2 |
|
− | end |
||
− | else |
||
− | v_margin_output_1 = math.ceil( ( h_size - 36 * ( output_rows + fluid_output_rows ) ) / 3 ) |
||
− | v_margin_output_2 = v_margin_output_1 |
||
end |
end |
||
+ | else |
||
− | |||
+ | v_margin_output_1 = math.ceil((h_size - 36 * (output_rows + fluid_output_rows)) / 3) |
||
+ | v_margin_output_2 = v_margin_output_1 |
||
+ | end |
||
+ | |||
-- выравнивание положения жидкостных ячеек |
-- выравнивание положения жидкостных ячеек |
||
− | + | if (fluid_input_rows ~= '0' and fluid_output_rows ~= '0') and (input_rows ~= '0' or output_rows ~= '0') |
|
− | + | then |
|
− | + | local max_fluid_rows = fluid_output_rows |
|
− | + | if fluid_input_rows > fluid_output_rows then |
|
− | + | max_fluid_rows = fluid_input_rows |
|
− | end |
||
− | v_margin_input_2 = ( h_size - 14 - 36 * ( input_rows + max_fluid_rows ) ) / 2 |
||
− | v_margin_input_1 = v_margin_input_2 + 6 |
||
− | v_margin_output_2 = ( h_size - 14 - 36 * ( output_rows + max_fluid_rows ) ) / 2 |
||
− | v_margin_output_1 = v_margin_output_2 + 6 |
||
end |
end |
||
+ | v_margin_input_2 = (h_size - 14 - 36 * (input_rows + max_fluid_rows)) / 2 |
||
+ | v_margin_input_1 = v_margin_input_2 + 6 |
||
+ | v_margin_output_2 = (h_size - 14 - 36 * (output_rows + max_fluid_rows)) / 2 |
||
+ | v_margin_output_1 = v_margin_output_2 + 6 |
||
+ | end |
||
− | + | recipe:css('margin-left', math.floor(0.75 * h_margin) .. 'px') |
|
-- Исходные предметы |
-- Исходные предметы |
||
− | + | local input = recipe:tag('span'):addClass('gt-input') |
|
− | + | input:css('margin-top', v_margin_input_1 .. 'px') |
|
− | + | local num = 0 |
|
− | + | for i = 1, input_rows do |
|
+ | for j = 1, input_cols do |
||
− | local row = input:tag('div'):addClass('mcui-row') |
||
− | + | num = num + 1 |
|
+ | if args["Ресурс" .. num] ~= 'none' then |
||
− | num = num + 1 |
||
− | if args["Ресурс" .. num] |
+ | if (args["Параметр"] and string.find(args["Ресурс" .. num], 'Интегральная схема')) |
+ | then |
||
− | if ( args["Параметр"] and string.find( args["Ресурс" .. num], 'Интегральная схема') ) |
||
+ | args["Ресурс" .. num] = args["Ресурс" .. num] .. "[&7 Параметр: " .. args["Параметр"] .. "/]" |
||
− | then |
||
+ | end |
||
− | args["Ресурс" .. num] = args["Ресурс" .. num] .. "[&7 Параметр: " .. args["Параметр"] .. "/]" |
||
+ | local s = mw.ustring.lower(string.gsub(progress,' ','_',5) .. '_in' .. num) |
||
− | end |
||
+ | input:wikitext(addSlot(args, version, mod, 'Ресурс' .. num,s,class1)) |
||
− | local s = mw.ustring.lower(string.gsub(progress,' ','_',5) .. '_in' .. num) |
||
− | row:wikitext(addSlot(args, version, mod, 'Ресурс' .. num,s,class1)) |
||
− | end |
||
end |
end |
||
− | if ( input_pic == 1 and i == 1 ) |
||
− | then |
||
− | row = input:tag('div'):addClass('mcui-row') |
||
− | row:wikitext(fuelImg) |
||
− | end |
||
end |
end |
||
+ | if (input_pic == 1 and i == 1) |
||
+ | then |
||
+ | input:wikitext(fuelImg) |
||
+ | end |
||
+ | end |
||
-- Переменные для подсказки к жидкостям |
-- Переменные для подсказки к жидкостям |
||
− | + | local rfsplit |
|
− | + | local rfqsplit |
|
− | + | local rftsplit |
|
− | + | local pfsplit |
|
− | + | local pfqsplit |
|
− | + | local pftsplit |
|
− | + | local maxn = 0 |
|
+ | |||
+ | if fluid_input_rows > '0' then |
||
+ | input:css('text-align','right') |
||
+ | end |
||
-- Исходные жидкие ресурсы |
-- Исходные жидкие ресурсы |
||
− | + | num = 0 |
|
− | + | for i = 1, fluid_input_rows do |
|
− | + | local fluid_row = input:tag('div'):addClass('mcui-row') |
|
− | + | if i == 1 then |
|
− | + | fluid_row:css('margin-top', v_margin_input_2 .. 'px') |
|
− | + | end |
|
− | + | fluid_row:css('text-align', 'right') |
|
− | + | for j = 1, fluid_input_cols do |
|
− | + | num = num + 1 |
|
− | + | s = mw.ustring.lower(string.gsub(progress,' ','_',5) .. '_fluid_in' .. num) |
|
− | + | if args["РесурсЖ" .. num] |
|
− | + | then |
|
− | + | rfsplit = mw.text.split(args["РесурсЖ" .. num] , '%s*;%s*') |
|
− | + | maxn = table.maxn(rfsplit) or 0 |
|
− | + | if args["РЖК" .. num] |
|
− | + | then |
|
− | + | rfqsplit = mw.text.split(args["РЖК" .. num] , '%s*;%s*') |
|
− | + | if table.maxn(rfqsplit) > maxn then maxn = table.maxn(rfqsplit) end |
|
− | + | end |
|
− | + | if args["РЖТ" .. num] |
|
− | + | then |
|
− | + | rftsplit = mw.text.split(args["РЖТ" .. num] , '%s*;%s*') |
|
− | + | if table.maxn(rftsplit) > maxn then maxn = table.maxn(rftsplit) end |
|
+ | end |
||
+ | for i = 1, maxn do |
||
+ | if (i > 1 and table.maxn(rfsplit) == 1) |
||
+ | then |
||
+ | table.insert(rfsplit,rfsplit[1]) |
||
end |
end |
||
− | + | if rfsplit[i] ~= '' then |
|
+ | rfsplit[i] = rfsplit[i] .. '[' |
||
− | if ( i > 1 and table.maxn(rfsplit) == 1 ) |
||
+ | if (args["Параметр"] and string.find(args["РесурсЖ" .. num], 'Интегральная схема')) |
||
− | then |
||
+ | then |
||
− | table.insert( rfsplit,rfsplit[1] ) |
||
+ | rfsplit[i] = rfsplit[i] .. "&7 Параметр: " .. args["Параметр"] .. "/" |
||
end |
end |
||
− | if |
+ | if (args["РЖК" .. num] and rfqsplit and rfqsplit[i] and rfqsplit[i] ~= '') |
+ | then |
||
− | rfsplit[i] = rfsplit[i] .. '[' |
||
+ | rfsplit[i] = rfsplit[i] .. "/&9 Объём: " .. rfqsplit[i] .. " мВ/" |
||
− | if ( args["Параметр"] and string.find( args["РесурсЖ" .. num], 'Интегральная схема') ) |
||
− | + | else |
|
+ | if (rfqsplit and rfqsplit[1] ~= '') |
||
− | rfsplit[i] = rfsplit[i] .. "&7 Параметр: " .. args["Параметр"] .. "/" |
||
+ | then |
||
+ | rfsplit[i] = rfsplit[i] .. "/&9 Объём: " .. rfqsplit[1] .. " мВ/" |
||
+ | end |
||
end |
end |
||
− | + | if (args["РЖТ" .. num] and rftsplit and rftsplit[i] and rftsplit[i] ~= '') |
|
− | + | then |
|
− | + | rfsplit[i] = rfsplit[i] .. "&c Температура: " .. rftsplit[i] .. " К/" |
|
− | + | else |
|
− | + | if (rftsplit and rftsplit[1] ~= '') |
|
− | + | then |
|
− | + | rfsplit[i] = rfsplit[i] .. "&c Температура: " .. rftsplit[1] .. " К/" |
|
− | + | end |
|
− | + | end |
|
− | + | rfsplit[i] = rfsplit[i] .. ']' |
|
− | then |
||
− | rfsplit[i] = rfsplit[i] .. "&c Температура: " .. rftsplit[i] .. " К/" |
||
− | else |
||
− | if ( rftsplit and rftsplit[1] ~= '' ) |
||
− | then |
||
− | rfsplit[i] = rfsplit[i] .. "&c Температура: " .. rftsplit[1] .. " К/" |
||
− | end |
||
− | end |
||
− | rfsplit[i] = rfsplit[i] .. ']' |
||
− | end |
||
end |
end |
||
− | args["РесурсЖ" .. num] = table.concat(rfsplit , ';') |
||
− | rfsplit = nil |
||
− | rfqsplit = nil |
||
− | rftsplit = nil |
||
end |
end |
||
+ | args["РесурсЖ" .. num] = table.concat(rfsplit , ';') |
||
− | fluid_row:wikitext(addSlot(args, version, mod, 'РесурсЖ' .. num,s)) |
||
+ | rfsplit = nil |
||
− | end |
||
+ | rfqsplit = nil |
||
+ | rftsplit = nil |
||
+ | end |
||
+ | fluid_row:wikitext(addSlot(args, version, mod, 'РесурсЖ' .. num,s)) |
||
end |
end |
||
+ | end |
||
-- Изображение стрелки прогресса |
-- Изображение стрелки прогресса |
||
− | + | local arrow = recipe:tag('span'):addClass('invslot-item ') |
|
− | + | arrow:attr('data-minetip-title','Обработчик:') |
|
− | + | arrow:css('margin', 'auto ' .. math.floor(0.25 * h_margin) .. 'px') |
|
− | + | if machine_list and version ~= 'Оригинальная игра' then |
|
− | + | arrow:wikitext('[[' .. version .. '/' .. progress .. '|') |
|
− | + | arrowtext = arrowtext .. version |
|
− | + | local ArrowImg = arrow:tag('span'):addClass('sprite') |
|
− | + | -- Отступы стрелки |
|
− | + | -- |
|
− | + | ArrowImg:css('background-image', '{{FileUrl|' .. arrow_version .. '_ArrowProcessingCSS.png}}') |
|
− | + | ArrowImg:css('height', arrow_height .. 'px') |
|
− | + | ArrowImg:css('width', arrow_width .. 'px') |
|
− | + | -- Координаты |
|
− | + | ArrowImg:css('background-position', '-' .. left * scale .. 'px -' .. top * scale ..'px') |
|
− | + | -- Масштаб |
|
− | + | if scale ~= 1 then |
|
− | + | ArrowImg:css('background-size', sheetWidth * scale .. 'px auto') |
|
− | + | end |
|
− | + | ArrowImg:wikitext(' ') |
|
− | + | arrow:wikitext(']]') |
|
+ | else |
||
+ | if progress ~= 'Печь' and mod then |
||
+ | arrowtext = arrowtext .. mod |
||
+ | arrow:wikitext('[[Файл:Grid layout ' .. progress .. ' Progress (' .. mod .. ').png|link=' .. mod .. '/' .. progress .. ']]') |
||
else |
else |
||
+ | arrow:wikitext('[[Файл:Grid_layout_Furnace_Progress.png|link=Печь]]') |
||
− | if progress ~= 'Печь' and mod then |
||
− | arrowtext = arrowtext .. mod |
||
− | arrow:wikitext('[[Файл:Grid layout ' .. progress .. ' Progress (' .. mod .. ').png|link=' .. mod .. '/' .. progress .. ']]') |
||
− | else |
||
− | arrow:wikitext('[[Файл:Grid_layout_Furnace_Progress.png|link=Печь]]') |
||
− | end |
||
− | arrow:css('width', arrow_width .. 'px') |
||
end |
end |
||
− | arrow: |
+ | arrow:css('width', arrow_width .. 'px') |
+ | end |
||
+ | arrow:attr('data-minetip-text', arrowtext) |
||
-- Центральная ячейка |
-- Центральная ячейка |
||
− | + | local mid_input = machine["Mid_input"] or '0' |
|
− | + | for i = 1, mid_input do |
|
− | + | local mid_cell = recipe:tag('span'):addClass('mcui-row') |
|
− | + | mid_cell:css('position', 'absolute') |
|
− | + | if progress ~= 'Режущий механизм' then |
|
− | + | mid_cell:css('left', h_margin + input_size + (arrow_width - 36) / 2 .. 'px') |
|
− | + | mid_cell:css('top', '94px') |
|
− | + | s = mw.ustring.lower(string.gsub(progress,' ','_',5) .. '_mid') |
|
− | + | mid_cell:wikitext(addSlot(args, version, mod, 'РесурсЦ',s)) |
|
− | + | else |
|
− | + | mid_cell:css('left', h_margin + input_size + (arrow_width - 36) / 2 + 2 .. 'px') |
|
− | + | mid_cell:css('top', '54px') |
|
− | + | mid_cell:wikitext(addSlot(args, version, mod, 'Диск','','invslot-plain')) |
|
− | end |
||
end |
end |
||
+ | end |
||
-- Получаемые предметы |
-- Получаемые предметы |
||
− | + | local output = recipe:tag('span'):addClass('gt-output') |
|
− | + | output:css('margin-top', v_margin_output_1 - large .. 'px') |
|
− | + | num = 0 |
|
− | + | for i = 1, output_rows do |
|
+ | for j = 1, output_cols do |
||
− | row = output:tag('div'):addClass('mcui-row') |
||
+ | num = num + 1 |
||
− | row:css('text-align', 'left') |
||
+ | s = mw.ustring.lower(string.gsub(progress,' ','_',5) .. '_out' .. num) |
||
− | for j = 1, output_cols do |
||
+ | if args["Шанс" .. num] |
||
− | num = num + 1 |
||
+ | then |
||
− | s = mw.ustring.lower(string.gsub(progress,' ','_',5) .. '_out' .. num) |
||
− | + | local rfsplit = mw.text.split(args["Выход" .. num] , '%s*;%s*') |
|
+ | local rfqsplit = mw.text.split(args["Шанс" .. num] , '%s*;%s*') |
||
− | then |
||
+ | while table.maxn(rfqsplit) > table.maxn(rfsplit) |
||
− | local rfsplit = mw.text.split( args["Выход" .. num] , '%s*;%s*') |
||
+ | do |
||
− | local rfqsplit = mw.text.split( args["Шанс" .. num] , '%s*;%s*') |
||
− | + | table.insert(rfsplit,rfsplit[1]) |
|
− | do |
||
− | table.insert(rfsplit,rfsplit[1]) |
||
− | end |
||
− | while table.maxn(rfsplit) > table.maxn(rfqsplit) |
||
− | do |
||
− | table.insert(rfqsplit,rfqsplit[1]) |
||
− | end |
||
− | for i = 1, table.maxn(rfsplit) do |
||
− | if ( rfqsplit[i] and rfqsplit[i] > '0' ) |
||
− | then |
||
− | rfsplit[i] = rfsplit[i] .. "[&7 Шанс получения: " .. rfqsplit[i] .. "%/]" |
||
− | end |
||
− | args["Выход" .. num] = table.concat(rfsplit , ';') |
||
end |
end |
||
+ | while table.maxn(rfsplit) > table.maxn(rfqsplit) |
||
+ | do |
||
+ | table.insert(rfqsplit,rfqsplit[1]) |
||
+ | end |
||
+ | for i = 1, table.maxn(rfsplit) do |
||
+ | if (rfqsplit[i] and rfqsplit[i] > '0') |
||
+ | then |
||
+ | rfsplit[i] = rfsplit[i] .. "[&7 Шанс получения: " .. rfqsplit[i] .. "%/]" |
||
+ | end |
||
+ | args["Выход" .. num] = table.concat(rfsplit , ';') |
||
end |
end |
||
+ | end |
||
− | row:wikitext(addSlot(args, version, mod, 'Выход' .. num,s,class2)) |
||
+ | output:wikitext(addSlot(args, version, mod, 'Выход' .. num,s,class2)) |
||
− | end |
||
end |
end |
||
+ | end |
||
-- Строка текста под получаемыми ресурсами |
-- Строка текста под получаемыми ресурсами |
||
− | + | if args["Температура"] or args["Опыт"] |
|
− | + | then |
|
− | + | local margin_out_2 = output:tag('span'):addClass('mcui-row') |
|
− | + | margin_out_2:css('margin-top','6px') |
|
− | + | if args["Температура"] then |
|
− | + | local margin_out_2_text = margin_out_2:tag('span') |
|
− | + | margin_out_2_text = help_string(margin_out_2_text, animate(args["Температура"]) .. ' К', 'Необходимая температура печи в кельвинах.') |
|
− | + | elseif args["Опыт"] then |
|
− | + | margin_out_2:css('font-family', 'Minecraft-ru, sans-serif') |
|
− | + | margin_out_2:wikitext(require('Модуль:Спрайт').base{ ['изобр'] = 'Сферы_опыта.png', ['выравн'] = 'text-bottom' }) |
|
− | + | local margin_out_3_text = margin_out_2:tag('span') |
|
− | + | margin_out_3_text = help_string(margin_out_3_text, animate(args["Опыт"]), 'Дробная часть показывает вероятность получения единицы опыта.') |
|
− | end |
||
end |
end |
||
+ | end |
||
+ | |||
+ | |||
+ | if fluid_output_rows > '0' then |
||
+ | output:css('text-align','left') |
||
+ | end |
||
-- Получаемые жидкие ресурсы |
-- Получаемые жидкие ресурсы |
||
− | + | num = 0 |
|
− | + | for i = 1, fluid_output_rows do |
|
− | + | fluid_row = output:tag('div'):addClass('mcui-row') |
|
− | + | fluid_row:css('text-align', 'left') |
|
− | + | if i == 1 then |
|
− | + | fluid_row:css('margin-top', v_margin_output_2 .. 'px') |
|
− | + | end |
|
− | + | for j = 1, fluid_output_cols do |
|
− | + | num = num + 1 |
|
− | + | s = mw.ustring.lower(string.gsub(progress,' ','_',5) .. '_fluid_out' .. num) |
|
− | + | if args["ВыходЖ" .. num] |
|
− | + | then |
|
− | + | pfsplit = mw.text.split(args["ВыходЖ" .. num] , '%s*;%s*') |
|
− | + | maxn = table.maxn(pfsplit) or 0 |
|
− | + | if args["ВЖК" .. num] |
|
− | + | then |
|
− | + | pfqsplit = mw.text.split(args["ВЖК" .. num] , '%s*;%s*') |
|
− | + | if table.maxn(pfqsplit) > maxn then maxn = table.maxn(pfqsplit) end |
|
− | + | end |
|
− | + | if args["ВЖТ" .. num] |
|
− | + | then |
|
− | + | pftsplit = mw.text.split(args["ВЖТ" .. num] , '%s*;%s*') |
|
− | + | if table.maxn(pftsplit) > maxn then maxn = table.maxn(pftsplit) end |
|
+ | end |
||
+ | for i = 1, maxn do |
||
+ | if (i > 1 and table.maxn(pfsplit) == 1) |
||
+ | then |
||
+ | table.insert(pfsplit,pfsplit[1]) |
||
end |
end |
||
− | + | if pfsplit[i] ~= '' then |
|
+ | pfsplit[i] = pfsplit[i] .. '[' |
||
− | if ( i > 1 and table.maxn(pfsplit) == 1 ) |
||
+ | if (args["Параметр"] and string.find(args["ВыходЖ" .. num], 'Интегральная схема')) |
||
− | then |
||
+ | then |
||
− | table.insert( pfsplit,pfsplit[1] ) |
||
+ | pfsplit[i] = pfsplit[i] .. "&7 Параметр: " .. args["Параметр"] .. "/" |
||
end |
end |
||
− | if |
+ | if (args["ВЖК" .. num] and pfqsplit and pfqsplit[i] and pfqsplit[i] ~= '') |
+ | then |
||
− | pfsplit[i] = pfsplit[i] .. '[' |
||
+ | pfsplit[i] = pfsplit[i] .. "/&9 Объём: " .. pfqsplit[i] .. " мВ/" |
||
− | if ( args["Параметр"] and string.find( args["ВыходЖ" .. num], 'Интегральная схема') ) |
||
− | + | else |
|
+ | if (pfqsplit and pfqsplit[1] ~= '') |
||
− | pfsplit[i] = pfsplit[i] .. "&7 Параметр: " .. args["Параметр"] .. "/" |
||
+ | then |
||
+ | pfsplit[i] = pfsplit[i] .. "/&9 Объём: " .. pfqsplit[1] .. " мВ/" |
||
+ | end |
||
end |
end |
||
− | + | if (args["ВЖТ" .. num] and pftsplit and pftsplit[i] and pftsplit[i] ~= '') |
|
− | + | then |
|
− | + | pfsplit[i] = pfsplit[i] .. "&c Температура: " .. pftsplit[i] .. " К/" |
|
− | + | else |
|
− | + | if (pftsplit and pftsplit[1] ~= '') |
|
− | + | then |
|
− | + | pfsplit[i] = pfsplit[i] .. "&c Температура: " .. pftsplit[1] .. " К/" |
|
− | + | end |
|
− | + | end |
|
− | + | pfsplit[i] = pfsplit[i] .. ']' |
|
− | then |
||
− | pfsplit[i] = pfsplit[i] .. "&c Температура: " .. pftsplit[i] .. " К/" |
||
− | else |
||
− | if ( pftsplit and pftsplit[1] ~= '' ) |
||
− | then |
||
− | pfsplit[i] = pfsplit[i] .. "&c Температура: " .. pftsplit[1] .. " К/" |
||
− | end |
||
− | end |
||
− | pfsplit[i] = pfsplit[i] .. ']' |
||
− | end |
||
end |
end |
||
− | args["ВыходЖ" .. num] = table.concat(pfsplit , ';') |
||
− | pfsplit = nil |
||
− | pfqsplit = nil |
||
− | pftsplit = nil |
||
end |
end |
||
+ | args["ВыходЖ" .. num] = table.concat(pfsplit , ';') |
||
− | fluid_row:wikitext(addSlot(args, version, mod, 'ВыходЖ' .. num,s)) |
||
+ | pfsplit = nil |
||
− | end |
||
+ | pfqsplit = nil |
||
+ | pftsplit = nil |
||
+ | end |
||
+ | fluid_row:wikitext(addSlot(args, version, mod, 'ВыходЖ' .. num,s)) |
||
end |
end |
||
+ | end |
||
− | |||
+ | |||
− | h_size = h_size - 9 |
||
+ | h_size = h_size - 9 |
||
− | |||
+ | |||
-- Конструктор строк потребления |
-- Конструктор строк потребления |
||
− | local EString = function( |
+ | local EString = function(EBody_Title, EBody_Help, arg, EBody_Unit) |
− | + | local EBody = body:tag('div'):addClass('gui-set-line') |
|
− | + | EBody:css('position', 'relative') |
|
− | + | local EBody_Text = EBody:tag('span'):addClass('mcui-row') |
|
− | + | EBody_Text:css('margin-left', '22px') |
|
− | + | EBody_Text:css('text-align', 'left') |
|
− | + | EBody_Text = help_string(EBody_Text, EBody_Title, EBody_Help) |
|
− | + | EBody:wikitext(' ' .. animate(arg) .. ' ') |
|
− | + | if EBody_Unit then |
|
− | + | EBody:wikitext(EBody_Unit) |
|
− | end |
||
− | h_size = h_size + 21 |
||
− | return EBody |
||
end |
end |
||
+ | h_size = h_size + 21 |
||
− | |||
+ | return EBody |
||
+ | end |
||
+ | |||
-- Строки потребления |
-- Строки потребления |
||
− | + | if args["Пар"] then |
|
− | + | local vape = EString ('Пар:' , 'Объём пара, требующийся для проведения операции.' , args ["Пар"]) |
|
− | + | local vapeunit = vape:tag('span') |
|
− | + | vapeunit = help_string(vapeunit, 'мВ', 'Милливедро (мВ) — единица объёма условно равная 1/1000 части ведра.') |
|
− | + | end |
|
− | |||
− | if args["Старт"] then |
||
− | local start = EString ( 'Старт:' , 'Энергия, требующаяся на запуск процесса.' , args ["Старт"], '[[IndustrialCraft_2|еЭ]]') |
||
− | end |
||
− | |||
− | if args["Энергия"] then |
||
− | local energy = EString ( 'Энергия:' , 'Энергия, затрачиваемая на каждую операцию.' , args ["Энергия"], '[[IndustrialCraft_2|еЭ]]') |
||
− | end |
||
− | + | if args["Старт"] then |
|
− | + | local start = EString ('Старт:' , 'Энергия, требующаяся на запуск процесса.' , args ["Старт"], '[[IndustrialCraft_2|еЭ]]') |
|
− | + | end |
|
+ | |||
+ | if args["Энергия"] then |
||
+ | local energy = EString ('Энергия:' , 'Энергия, затрачиваемая на каждую операцию.' , args ["Энергия"], '[[IndustrialCraft_2|еЭ]]') |
||
+ | end |
||
− | + | if args["Потребление"] then |
|
− | + | local consumption = EString ('Потребление:' , 'Скорость потребления энергии.' , args ["Потребление"], '[[IndustrialCraft_2|еЭ]]/[[Такт|т]]') |
|
− | + | end |
|
+ | |||
+ | if args["Напряжение"] then |
||
+ | local voltage = EString ('Напряжение:' , 'Требуемое для операции напряжение.' , args ["Напряжение"], '[[IndustrialCraft_2|еЭ]]/[[Такт|т]]') |
||
+ | end |
||
+ | |||
+ | if args["Сила тока"] then |
||
+ | local amper = EString ('Напряжение:' , 'Требуемая для операции сила тока.' , args ["Сила тока"]) |
||
+ | end |
||
− | + | if args["Время"] then |
|
− | + | local timer = EString ('Время:' , 'Время, затрачиваемое на операцию.' , args ["Время"], 'сек.') |
|
− | + | end |
|
− | |||
− | if args["Время"] then |
||
− | local timer = EString ( 'Время:' , 'Время, затрачиваемое на операцию.' , args ["Время"], 'сек.') |
||
− | end |
||
-- Определение фоновой картинки на основании высоты |
-- Определение фоновой картинки на основании высоты |
||
− | + | if h_size > 140 then |
|
− | + | body:css('height', h_size + 8 .. 'px') |
|
+ | end |
||
+ | body:addClass('gui-set ' .. style .. ' gui') |
||
+ | body:css('z-index', '1') |
||
+ | |||
+ | if machine_list["Logo"] and (machine["Logo"] or '1') ~= '0' then |
||
+ | local GTlogo = body:tag('div'):addClass('gt-pic') |
||
+ | if machine["Skin"] then |
||
+ | GTlogo:addClass('gt-' .. machine["Skin"] .. '-pic') |
||
+ | else |
||
+ | GTlogo:addClass('gt-' .. machine_list["Logo"] .. '-pic') |
||
end |
end |
||
+ | end |
||
− | body:addClass('gui-set ' .. style .. ' gui' ) |
||
+ | |||
− | body:css( 'z-index', '1' ) |
||
+ | if progress == 'Формовщик металла' and args["Режим"] then |
||
− | |||
+ | local mode = recipe:tag('div'):addClass('invslot-item') |
||
− | if machine_list["Logo"] and ( machine["Logo"] or '1' ) ~= '0' then |
||
+ | mode:css('position', 'absolute') |
||
− | local GTlogo = body:tag('div'):addClass('gt-pic') |
||
+ | mode:css('top', '86px') |
||
− | if machine["Skin"] then |
||
+ | mode:css('left', '113px') |
||
− | GTlogo:addClass('gt-' .. machine["Skin"] .. '-pic') |
||
+ | mode:attr('data-minetip-title','Режим: ' .. args["Режим"]) |
||
− | else |
||
+ | mode:wikitext('[[Файл:Формовщик металла_(' .. args["Режим"] .. ')_(IndustrialCraft 2).png|link=]]') |
||
− | GTlogo:addClass('gt-' .. machine_list["Logo"] .. '-pic') |
||
− | + | end |
|
+ | |||
− | end |
||
+ | return tostring(body) |
||
− | |||
+ | |||
− | if progress == 'Формовщик металла' and args["Режим"] then |
||
− | local mode = body:tag('div'):addClass('invslot-item') |
||
− | mode:css('position', 'absolute') |
||
− | mode:css('top', '86px') |
||
− | mode:css('left', '113px') |
||
− | mode:attr('data-minetip-title','Режим: ' .. args["Режим"]) |
||
− | mode:wikitext('[[Файл:Формовщик металла_(' .. args["Режим"] .. ')_(IndustrialCraft 2).png|link=]]') |
||
− | end |
||
− | |||
− | return tostring( body ) |
||
end |
end |
||
Версия от 10:46, 3 апреля 2020
local slot = require('Модуль:Инвентарный слот').slot
local text = require('Модуль:Анимация').text
-- Функция добавления слота
local addSlot = function(args, version, mod, item, CSS, class, prefix, default)
prefix = prefix or item
return slot{
args[item], ["мод"] = mod, ["ссылка"] = args[prefix .. 'Ссылка'],
["назв"] = args[prefix .. 'Назв'], ["класс"] = class, ["умолчаниеCSS"] = CSS, ["Версия"] = version
}
end
-- Функция анимирования текста
local animate = function(txt)
return text{ txt }
end
-- Конструктор текста с подсказкой
local help_string = function (HBody, HTitle, HText)
HBody:css('border-bottom','1px dotted')
HBody:css('cursor','help')
HBody:attr('title', HText)
HBody:wikitext(HTitle)
return HBody
end
-- Контейнер интерфейса
local body = mw.html.create('div')
local recipe = body:tag('span'):addClass('gui-recipe')
-- Высота шаблона
local h_size = 140
-- Экспортируемые функции
local p = {}
p.interface = function(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
-- Параметры машины
local machine_list = mw.loadData('Модуль:ТестОбработка/Машины')
local versions = {
["GregTech 4"] = 'GregTech 4',
["gt4"] = 'GregTech 4',
["GT4"] = 'GregTech 4',
["GregTech 5"] = 'GregTech 5',
["gt5"] = 'GregTech 5',
["GT5"] = 'GregTech 5',
["GregTech 5 Unofficial"] = 'GregTech 5 Unofficial',
["gt5u"] = 'GregTech 5 Unofficial',
["GT5U"] = 'GregTech 5 Unofficial',
["GregTech 6"] = 'GregTech 6',
["gt6"] = 'GregTech 6',
["GT6"] = 'GregTech 6',
["IndustrialCraft 2"] = 'IndustrialCraft 2',
["ic2"] = 'IndustrialCraft 2',
["IC2"] = 'IndustrialCraft 2',
["Оригинальная игра"] = 'Оригинальная игра',
'&4Неизвестна',
}
local version
local progress = args["Прогресс"] or ''
local mod
if args["Мод"] ~= '' then
mod = args["Мод"]
end
if progress ~= '' then
version = mw.ustring.match(progress, ':%s*([a-zA-Zа-яА-ЯёЁ 0-9]+)') or args["Версия"] or mod
progress = mw.ustring.match(progress, '([a-zA-Zа-яА-ЯёЁ 0-9]+):') or progress or '&4Неизвестная машина'
else
version = args["Версия"] or 'Оригинальная игра'
progress = 'Печь'
end
if version then
if versions[version] then
version = versions[version]
else
version = versions[1]
end
end
if version == "GregTech 4" or version == "IndustrialCraft 2" then
mod = mod or version
elseif version == "GregTech 6" or version == "GregTech 5" or version == "GregTech 5 Unofficial" then
mod = mod or 'GregTech'
else
mod = mod or ''
end
machine_list = machine_list[version]
local machine = machine_list[progress]
local machine_code = args["Машина"] or machine[1]
-- Строк ячеек ресурса
local input_rows = string.sub(machine_code,1,1) or '1'
-- Столбцов ячеек ресурса
local input_cols = string.sub(machine_code,2,2) or '1'
-- Строк ячеек выхода
local output_rows = string.sub(machine_code,3,3) or '1'
-- Столбцов ячеек выхода
local output_cols = string.sub(machine_code,4,4) or '1'
-- Строк ячеек жидкого ресурса
local fluid_input_rows = string.sub(machine_code,5,5) or '0'
-- Столбцов ячеек жидкого ресурса
local fluid_input_cols = string.sub(machine_code,6,6) or '0'
-- Строк ячеек жидкого выхода
local fluid_output_rows = string.sub(machine_code,7,7) or '0'
-- Столбцов ячеек жидкого выхода
local fluid_output_cols = string.sub(machine_code,8,8) or '0'
-- Оригинальное название
local OrigName = mw.ustring.match(machine_code, ',%s*([-/()a-zA-Z 0-9]+)') or ''
-- Определитель стиля
local style = machine_list["Skin"]
if machine["Skin"] then
style = style .. '-' .. machine["Skin"]
end
local class1
local class2
local large = 0
if machine["Skin"] == 'bronze' then
class1 = 'bronze_invslot'
class2 = 'bronze_invslot'
elseif machine["Out_class"] then
class2 = 'invslot-large'
large = 8
end
-- Иконка реакции
local fuelImg
local input_pic = 0
if (machine_list["Image"] or machine["Image"]) and (input_rows + fluid_input_rows) > '1' then
fuelImg = machine["Image"] or machine_list["Image"]
input_pic = 1
elseif (args["Расход"] and mod ~= '') then
fuelImg = '[[Файл:Grid layout ' .. args["Расход"] .. ' (' .. mod .. ').png|link=|alt=]]'
end
-- Предопределённые аргументы
if machine_list["Def_args"] then
for k,v in pairs(machine_list["Def_args"]) do
args[k] = v
end
end
if machine and machine["Def_args"] then
for k,v in pairs(machine["Def_args"]) do
args[k] = v
end
end
-- Определители отступов
local input_size = 0
local v_margin_input_1 = 0
local v_margin_input_2 = 0
local output_size = 0
local v_margin_output_1 = 0
local v_margin_output_2 = 0
-- Переопределение количества получаемых предметов (1-4)
if args["Уровень"] then
output_rows = tostring(math.floor (args["Уровень"] / 4) + 1)
output_cols = tostring(args["Уровень"] / output_rows)
end
-- Предопределение или конвертация некоторых аргументов
args["Шанс1"] = args["Шанс1"] or args["Шанс"]
args["Ресурс1"] = args["Ресурс1"] or args["Ресурс"] or args[1]
args["Ресурс2"] = args["Ресурс2"] or args["Топливо"] or args["топливо"]
args["Выход1"] = args["Выход1"] or args["Выход"] or args[2]
args["РесурсЖ1"] = args["РесурсЖ1"] or args["РесурсЖ"]
args["РЖК1"] = args["РЖК1"] or args["РЖК"]
args["РЖТ1"] = args["РЖТ1"] or args["РЖТ"]
args["ВыходЖ1"] = args["ВыходЖ1"] or args["ВыходЖ"]
args["ВЖК1"] = args["ВЖК1"] or args["ВЖК"]
args["ВЖТ1"] = args["ВЖТ1"] or args["ВЖТ"]
if progress == 'Просеиватель' and version == 'GregTech 6' and args["Выход7"] then
args["Шанс1"] = '0.01'
args["Шанс2"] = '01'
args["Шанс3"] = '04'
args["Шанс4"] = '15'
args["Шанс5"] = '20'
args["Шанс6"] = '40'
args["Шанс7"] = '50'
end
-- Реорганизация интерфейса некоторых машин
if args["ОднаСтрока"]
then
input_rows = '0'
fluid_input_cols = '2'
args["РесурсЖ2"] = args["Ресурс1"]
end
-- Параметры стрелки прогресса
local ArrowIds = mw.loadData('Модуль:Обработка/Стрелки')
local param = {}
if ArrowIds[version] and ArrowIds[version]['Параметры'] then
param = ArrowIds[version]['Параметры']
else
param = {
["формат"] = 280,
["масштаб"] = 1,
["поз"] = 1,
["верт_разм"] = 48,
["разм"] = 56,
}
end
local ArrowID = 1
local arrow_version = version
local arrowtext = '&3' .. progress
if OrigName and OrigName ~= '' then
arrowtext = arrowtext .. '/&9' .. OrigName
end
if version ~= 'Оригинальная игра' then
arrowtext = arrowtext .. '//&7Модификация:/'
end
if version ~= '&4Неизвестна' and version ~= 'Оригинальная игра' then
if ArrowIds[version] and ArrowIds[version][progress] then
ArrowID = ArrowIds[version][progress]
else
arrowtext = arrowtext .. ' &4(Нет стрелки)'
end
else
arrow_version = 'GregTech 4'
end
if version == 'GregTech 5 Unofficial' then
arrow_version = 'GregTech 5'
end
local size = param["разм"] -- ширина спрайта в пикселях
local v_size = param["верт_разм"] -- высота спрайта в пикселях
local pos = ArrowID - 1 -- положение спрайта в таблице
local sheetWidth = param["формат"] -- ширина таблицы спрайта в пикселях
local tiles = sheetWidth / size -- количество спрайтов в одной строке
local left = pos % tiles * size -- горизонтальная координата спрайта
local top = math.floor(pos / tiles) * v_size -- вертикальная координата спрайта
local scale = param["масштаб"] -- масштаб спрайта (во сколько раз увеличить или уменьшить размер)
local arrow_width = (args['ширина_стрелки'] or size) * scale -- ширина спрайта с учётом масштаба
local arrow_height = (args['высота_стрелки'] or v_size) * scale -- высота спрайта с учётом масштаба
-- вычисление ширины зоны исходных ресурсов и разницы между количеством столбцов предметов и жидких ресурсов
if input_cols >= fluid_input_cols
then
input_size = input_cols * 36
else
input_size = fluid_input_cols * 36
end
-- Горизонтальные отступы
if output_cols >= fluid_output_cols
then
output_size = output_cols * 36
else
output_size = fluid_output_cols * 36
end
local h_margin = (282 - output_size - input_size - arrow_width) / 2 - large
if version == '&4Неизвестна' then
body:wikitext('[[Категория:Страницы с неизвестной версией машин]]')
end
-- Расширение при большом количестве строк
if (input_rows + fluid_input_rows) > 3 or (output_rows + fluid_output_rows) > 3 then
h_size = h_size + 21
recipe:css('height','161px')
end
-- центровка ячеек исходного ресурса
if (input_rows == '0' or fluid_input_rows == '0')
then
if fluid_input_rows == '0'
then
v_margin_input_1 = (h_size - 36 * (input_rows + input_pic)) / 2
else
v_margin_input_1 = (h_size - 36 * (fluid_input_rows)) / 2
end
elseif input_pic ~= 0 then
v_margin_input_1 = (h_size - 36 * (input_rows + input_pic + fluid_input_rows)) / 2
else
v_margin_input_1 = math.ceil((h_size - 36 * (input_rows + fluid_input_rows)) / 3)
v_margin_input_2 = v_margin_input_1
end
-- центровка ячеек получаемых материалов
if (output_rows == '0' or fluid_output_rows == '0')
then
if fluid_output_rows == '0'
then
v_margin_output_1 = (h_size - 36 * (output_rows)) / 2
else
v_margin_output_1 = (h_size - 36 * (fluid_output_rows)) / 2
end
else
v_margin_output_1 = math.ceil((h_size - 36 * (output_rows + fluid_output_rows)) / 3)
v_margin_output_2 = v_margin_output_1
end
-- выравнивание положения жидкостных ячеек
if (fluid_input_rows ~= '0' and fluid_output_rows ~= '0') and (input_rows ~= '0' or output_rows ~= '0')
then
local max_fluid_rows = fluid_output_rows
if fluid_input_rows > fluid_output_rows then
max_fluid_rows = fluid_input_rows
end
v_margin_input_2 = (h_size - 14 - 36 * (input_rows + max_fluid_rows)) / 2
v_margin_input_1 = v_margin_input_2 + 6
v_margin_output_2 = (h_size - 14 - 36 * (output_rows + max_fluid_rows)) / 2
v_margin_output_1 = v_margin_output_2 + 6
end
recipe:css('margin-left', math.floor(0.75 * h_margin) .. 'px')
-- Исходные предметы
local input = recipe:tag('span'):addClass('gt-input')
input:css('margin-top', v_margin_input_1 .. 'px')
local num = 0
for i = 1, input_rows do
for j = 1, input_cols do
num = num + 1
if args["Ресурс" .. num] ~= 'none' then
if (args["Параметр"] and string.find(args["Ресурс" .. num], 'Интегральная схема'))
then
args["Ресурс" .. num] = args["Ресурс" .. num] .. "[&7 Параметр: " .. args["Параметр"] .. "/]"
end
local s = mw.ustring.lower(string.gsub(progress,' ','_',5) .. '_in' .. num)
input:wikitext(addSlot(args, version, mod, 'Ресурс' .. num,s,class1))
end
end
if (input_pic == 1 and i == 1)
then
input:wikitext(fuelImg)
end
end
-- Переменные для подсказки к жидкостям
local rfsplit
local rfqsplit
local rftsplit
local pfsplit
local pfqsplit
local pftsplit
local maxn = 0
if fluid_input_rows > '0' then
input:css('text-align','right')
end
-- Исходные жидкие ресурсы
num = 0
for i = 1, fluid_input_rows do
local fluid_row = input:tag('div'):addClass('mcui-row')
if i == 1 then
fluid_row:css('margin-top', v_margin_input_2 .. 'px')
end
fluid_row:css('text-align', 'right')
for j = 1, fluid_input_cols do
num = num + 1
s = mw.ustring.lower(string.gsub(progress,' ','_',5) .. '_fluid_in' .. num)
if args["РесурсЖ" .. num]
then
rfsplit = mw.text.split(args["РесурсЖ" .. num] , '%s*;%s*')
maxn = table.maxn(rfsplit) or 0
if args["РЖК" .. num]
then
rfqsplit = mw.text.split(args["РЖК" .. num] , '%s*;%s*')
if table.maxn(rfqsplit) > maxn then maxn = table.maxn(rfqsplit) end
end
if args["РЖТ" .. num]
then
rftsplit = mw.text.split(args["РЖТ" .. num] , '%s*;%s*')
if table.maxn(rftsplit) > maxn then maxn = table.maxn(rftsplit) end
end
for i = 1, maxn do
if (i > 1 and table.maxn(rfsplit) == 1)
then
table.insert(rfsplit,rfsplit[1])
end
if rfsplit[i] ~= '' then
rfsplit[i] = rfsplit[i] .. '['
if (args["Параметр"] and string.find(args["РесурсЖ" .. num], 'Интегральная схема'))
then
rfsplit[i] = rfsplit[i] .. "&7 Параметр: " .. args["Параметр"] .. "/"
end
if (args["РЖК" .. num] and rfqsplit and rfqsplit[i] and rfqsplit[i] ~= '')
then
rfsplit[i] = rfsplit[i] .. "/&9 Объём: " .. rfqsplit[i] .. " мВ/"
else
if (rfqsplit and rfqsplit[1] ~= '')
then
rfsplit[i] = rfsplit[i] .. "/&9 Объём: " .. rfqsplit[1] .. " мВ/"
end
end
if (args["РЖТ" .. num] and rftsplit and rftsplit[i] and rftsplit[i] ~= '')
then
rfsplit[i] = rfsplit[i] .. "&c Температура: " .. rftsplit[i] .. " К/"
else
if (rftsplit and rftsplit[1] ~= '')
then
rfsplit[i] = rfsplit[i] .. "&c Температура: " .. rftsplit[1] .. " К/"
end
end
rfsplit[i] = rfsplit[i] .. ']'
end
end
args["РесурсЖ" .. num] = table.concat(rfsplit , ';')
rfsplit = nil
rfqsplit = nil
rftsplit = nil
end
fluid_row:wikitext(addSlot(args, version, mod, 'РесурсЖ' .. num,s))
end
end
-- Изображение стрелки прогресса
local arrow = recipe:tag('span'):addClass('invslot-item ')
arrow:attr('data-minetip-title','Обработчик:')
arrow:css('margin', 'auto ' .. math.floor(0.25 * h_margin) .. 'px')
if machine_list and version ~= 'Оригинальная игра' then
arrow:wikitext('[[' .. version .. '/' .. progress .. '|')
arrowtext = arrowtext .. version
local ArrowImg = arrow:tag('span'):addClass('sprite')
-- Отступы стрелки
--
ArrowImg:css('background-image', '{{FileUrl|' .. arrow_version .. '_ArrowProcessingCSS.png}}')
ArrowImg:css('height', arrow_height .. 'px')
ArrowImg:css('width', arrow_width .. 'px')
-- Координаты
ArrowImg:css('background-position', '-' .. left * scale .. 'px -' .. top * scale ..'px')
-- Масштаб
if scale ~= 1 then
ArrowImg:css('background-size', sheetWidth * scale .. 'px auto')
end
ArrowImg:wikitext(' ')
arrow:wikitext(']]')
else
if progress ~= 'Печь' and mod then
arrowtext = arrowtext .. mod
arrow:wikitext('[[Файл:Grid layout ' .. progress .. ' Progress (' .. mod .. ').png|link=' .. mod .. '/' .. progress .. ']]')
else
arrow:wikitext('[[Файл:Grid_layout_Furnace_Progress.png|link=Печь]]')
end
arrow:css('width', arrow_width .. 'px')
end
arrow:attr('data-minetip-text', arrowtext)
-- Центральная ячейка
local mid_input = machine["Mid_input"] or '0'
for i = 1, mid_input do
local mid_cell = recipe:tag('span'):addClass('mcui-row')
mid_cell:css('position', 'absolute')
if progress ~= 'Режущий механизм' then
mid_cell:css('left', h_margin + input_size + (arrow_width - 36) / 2 .. 'px')
mid_cell:css('top', '94px')
s = mw.ustring.lower(string.gsub(progress,' ','_',5) .. '_mid')
mid_cell:wikitext(addSlot(args, version, mod, 'РесурсЦ',s))
else
mid_cell:css('left', h_margin + input_size + (arrow_width - 36) / 2 + 2 .. 'px')
mid_cell:css('top', '54px')
mid_cell:wikitext(addSlot(args, version, mod, 'Диск','','invslot-plain'))
end
end
-- Получаемые предметы
local output = recipe:tag('span'):addClass('gt-output')
output:css('margin-top', v_margin_output_1 - large .. 'px')
num = 0
for i = 1, output_rows do
for j = 1, output_cols do
num = num + 1
s = mw.ustring.lower(string.gsub(progress,' ','_',5) .. '_out' .. num)
if args["Шанс" .. num]
then
local rfsplit = mw.text.split(args["Выход" .. num] , '%s*;%s*')
local rfqsplit = mw.text.split(args["Шанс" .. num] , '%s*;%s*')
while table.maxn(rfqsplit) > table.maxn(rfsplit)
do
table.insert(rfsplit,rfsplit[1])
end
while table.maxn(rfsplit) > table.maxn(rfqsplit)
do
table.insert(rfqsplit,rfqsplit[1])
end
for i = 1, table.maxn(rfsplit) do
if (rfqsplit[i] and rfqsplit[i] > '0')
then
rfsplit[i] = rfsplit[i] .. "[&7 Шанс получения: " .. rfqsplit[i] .. "%/]"
end
args["Выход" .. num] = table.concat(rfsplit , ';')
end
end
output:wikitext(addSlot(args, version, mod, 'Выход' .. num,s,class2))
end
end
-- Строка текста под получаемыми ресурсами
if args["Температура"] or args["Опыт"]
then
local margin_out_2 = output:tag('span'):addClass('mcui-row')
margin_out_2:css('margin-top','6px')
if args["Температура"] then
local margin_out_2_text = margin_out_2:tag('span')
margin_out_2_text = help_string(margin_out_2_text, animate(args["Температура"]) .. ' К', 'Необходимая температура печи в кельвинах.')
elseif args["Опыт"] then
margin_out_2:css('font-family', 'Minecraft-ru, sans-serif')
margin_out_2:wikitext(require('Модуль:Спрайт').base{ ['изобр'] = 'Сферы_опыта.png', ['выравн'] = 'text-bottom' })
local margin_out_3_text = margin_out_2:tag('span')
margin_out_3_text = help_string(margin_out_3_text, animate(args["Опыт"]), 'Дробная часть показывает вероятность получения единицы опыта.')
end
end
if fluid_output_rows > '0' then
output:css('text-align','left')
end
-- Получаемые жидкие ресурсы
num = 0
for i = 1, fluid_output_rows do
fluid_row = output:tag('div'):addClass('mcui-row')
fluid_row:css('text-align', 'left')
if i == 1 then
fluid_row:css('margin-top', v_margin_output_2 .. 'px')
end
for j = 1, fluid_output_cols do
num = num + 1
s = mw.ustring.lower(string.gsub(progress,' ','_',5) .. '_fluid_out' .. num)
if args["ВыходЖ" .. num]
then
pfsplit = mw.text.split(args["ВыходЖ" .. num] , '%s*;%s*')
maxn = table.maxn(pfsplit) or 0
if args["ВЖК" .. num]
then
pfqsplit = mw.text.split(args["ВЖК" .. num] , '%s*;%s*')
if table.maxn(pfqsplit) > maxn then maxn = table.maxn(pfqsplit) end
end
if args["ВЖТ" .. num]
then
pftsplit = mw.text.split(args["ВЖТ" .. num] , '%s*;%s*')
if table.maxn(pftsplit) > maxn then maxn = table.maxn(pftsplit) end
end
for i = 1, maxn do
if (i > 1 and table.maxn(pfsplit) == 1)
then
table.insert(pfsplit,pfsplit[1])
end
if pfsplit[i] ~= '' then
pfsplit[i] = pfsplit[i] .. '['
if (args["Параметр"] and string.find(args["ВыходЖ" .. num], 'Интегральная схема'))
then
pfsplit[i] = pfsplit[i] .. "&7 Параметр: " .. args["Параметр"] .. "/"
end
if (args["ВЖК" .. num] and pfqsplit and pfqsplit[i] and pfqsplit[i] ~= '')
then
pfsplit[i] = pfsplit[i] .. "/&9 Объём: " .. pfqsplit[i] .. " мВ/"
else
if (pfqsplit and pfqsplit[1] ~= '')
then
pfsplit[i] = pfsplit[i] .. "/&9 Объём: " .. pfqsplit[1] .. " мВ/"
end
end
if (args["ВЖТ" .. num] and pftsplit and pftsplit[i] and pftsplit[i] ~= '')
then
pfsplit[i] = pfsplit[i] .. "&c Температура: " .. pftsplit[i] .. " К/"
else
if (pftsplit and pftsplit[1] ~= '')
then
pfsplit[i] = pfsplit[i] .. "&c Температура: " .. pftsplit[1] .. " К/"
end
end
pfsplit[i] = pfsplit[i] .. ']'
end
end
args["ВыходЖ" .. num] = table.concat(pfsplit , ';')
pfsplit = nil
pfqsplit = nil
pftsplit = nil
end
fluid_row:wikitext(addSlot(args, version, mod, 'ВыходЖ' .. num,s))
end
end
h_size = h_size - 9
-- Конструктор строк потребления
local EString = function(EBody_Title, EBody_Help, arg, EBody_Unit)
local EBody = body:tag('div'):addClass('gui-set-line')
EBody:css('position', 'relative')
local EBody_Text = EBody:tag('span'):addClass('mcui-row')
EBody_Text:css('margin-left', '22px')
EBody_Text:css('text-align', 'left')
EBody_Text = help_string(EBody_Text, EBody_Title, EBody_Help)
EBody:wikitext(' ' .. animate(arg) .. ' ')
if EBody_Unit then
EBody:wikitext(EBody_Unit)
end
h_size = h_size + 21
return EBody
end
-- Строки потребления
if args["Пар"] then
local vape = EString ('Пар:' , 'Объём пара, требующийся для проведения операции.' , args ["Пар"])
local vapeunit = vape:tag('span')
vapeunit = help_string(vapeunit, 'мВ', 'Милливедро (мВ) — единица объёма условно равная 1/1000 части ведра.')
end
if args["Старт"] then
local start = EString ('Старт:' , 'Энергия, требующаяся на запуск процесса.' , args ["Старт"], '[[IndustrialCraft_2|еЭ]]')
end
if args["Энергия"] then
local energy = EString ('Энергия:' , 'Энергия, затрачиваемая на каждую операцию.' , args ["Энергия"], '[[IndustrialCraft_2|еЭ]]')
end
if args["Потребление"] then
local consumption = EString ('Потребление:' , 'Скорость потребления энергии.' , args ["Потребление"], '[[IndustrialCraft_2|еЭ]]/[[Такт|т]]')
end
if args["Напряжение"] then
local voltage = EString ('Напряжение:' , 'Требуемое для операции напряжение.' , args ["Напряжение"], '[[IndustrialCraft_2|еЭ]]/[[Такт|т]]')
end
if args["Сила тока"] then
local amper = EString ('Напряжение:' , 'Требуемая для операции сила тока.' , args ["Сила тока"])
end
if args["Время"] then
local timer = EString ('Время:' , 'Время, затрачиваемое на операцию.' , args ["Время"], 'сек.')
end
-- Определение фоновой картинки на основании высоты
if h_size > 140 then
body:css('height', h_size + 8 .. 'px')
end
body:addClass('gui-set ' .. style .. ' gui')
body:css('z-index', '1')
if machine_list["Logo"] and (machine["Logo"] or '1') ~= '0' then
local GTlogo = body:tag('div'):addClass('gt-pic')
if machine["Skin"] then
GTlogo:addClass('gt-' .. machine["Skin"] .. '-pic')
else
GTlogo:addClass('gt-' .. machine_list["Logo"] .. '-pic')
end
end
if progress == 'Формовщик металла' and args["Режим"] then
local mode = recipe:tag('div'):addClass('invslot-item')
mode:css('position', 'absolute')
mode:css('top', '86px')
mode:css('left', '113px')
mode:attr('data-minetip-title','Режим: ' .. args["Режим"])
mode:wikitext('[[Файл:Формовщик металла_(' .. args["Режим"] .. ')_(IndustrialCraft 2).png|link=]]')
end
return tostring(body)
end
return p