Fix error when technic is used with i3 and without craftguide mod. Optimalize code.

This commit is contained in:
SFENCE 2021-03-29 08:35:14 +02:00
parent 1b83798f4e
commit 2e19e5db63
1 changed files with 21 additions and 26 deletions

View File

@ -8,22 +8,24 @@ function technic.register_recipe_type(typename, origdata)
for k, v in pairs(origdata) do data[k] = v end for k, v in pairs(origdata) do data[k] = v end
data.input_size = data.input_size or 1 data.input_size = data.input_size or 1
data.output_size = data.output_size or 1 data.output_size = data.output_size or 1
if have_ui and unified_inventory.register_craft_type and data.output_size == 1 then if data.output_size == 1 then
unified_inventory.register_craft_type(typename, { if have_ui and unified_inventory.register_craft_type then
description = data.description, unified_inventory.register_craft_type(typename, {
width = data.input_size, description = data.description,
height = 1, width = data.input_size,
}) height = 1,
end })
if have_cg and craftguide.register_craft_type and data.output_size == 1 then end
craftguide.register_craft_type(typename, { if have_cg and craftguide.register_craft_type then
description = data.description, craftguide.register_craft_type(typename, {
}) description = data.description,
end })
if have_i3 and i3.register_craft_type and data.output_size == 1 then end
i3.register_craft_type(typename, { if have_i3 then
description = data.description, i3.register_craft_type(typename, {
}) description = data.description,
})
end
end end
data.recipes = {} data.recipes = {}
technic.recipes[typename] = data technic.recipes[typename] = data
@ -72,20 +74,13 @@ local function register_recipe(typename, data)
}) })
end end
if (have_cg or have_i3) and technic.recipes[typename].output_size == 1 then if (have_cg or have_i3) and technic.recipes[typename].output_size == 1 then
if (craftguide.register_craft or have_i3) then if (have_cg or have_i3) then
local result = data.output; local result = data.output;
if (type(result)=="table") then if (type(result)=="table") then
result = result[1]; result = result[1];
end end
local items = ""; local items = table.concat(data.input, ", ");
for _, input in pairs(data.input) do if have_cg and craftguide.register_craft then
if (items=="") then
items = items..input;
else
items = items..", "..input;
end
end
if craftguide.register_craft then
craftguide.register_craft({ craftguide.register_craft({
type = typename, type = typename,
result = result, result = result,