mirror of
https://github.com/minetest-mods/technic.git
synced 2024-09-28 23:30:42 +02:00
Fix error when technic is used with i3 and without craftguide mod. Optimalize code.
This commit is contained in:
parent
1b83798f4e
commit
2e19e5db63
|
@ -8,22 +8,24 @@ function technic.register_recipe_type(typename, origdata)
|
|||
for k, v in pairs(origdata) do data[k] = v end
|
||||
data.input_size = data.input_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
|
||||
unified_inventory.register_craft_type(typename, {
|
||||
description = data.description,
|
||||
width = data.input_size,
|
||||
height = 1,
|
||||
})
|
||||
end
|
||||
if have_cg and craftguide.register_craft_type and data.output_size == 1 then
|
||||
craftguide.register_craft_type(typename, {
|
||||
description = data.description,
|
||||
})
|
||||
end
|
||||
if have_i3 and i3.register_craft_type and data.output_size == 1 then
|
||||
i3.register_craft_type(typename, {
|
||||
description = data.description,
|
||||
})
|
||||
if data.output_size == 1 then
|
||||
if have_ui and unified_inventory.register_craft_type then
|
||||
unified_inventory.register_craft_type(typename, {
|
||||
description = data.description,
|
||||
width = data.input_size,
|
||||
height = 1,
|
||||
})
|
||||
end
|
||||
if have_cg and craftguide.register_craft_type then
|
||||
craftguide.register_craft_type(typename, {
|
||||
description = data.description,
|
||||
})
|
||||
end
|
||||
if have_i3 then
|
||||
i3.register_craft_type(typename, {
|
||||
description = data.description,
|
||||
})
|
||||
end
|
||||
end
|
||||
data.recipes = {}
|
||||
technic.recipes[typename] = data
|
||||
|
@ -72,20 +74,13 @@ local function register_recipe(typename, data)
|
|||
})
|
||||
end
|
||||
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;
|
||||
if (type(result)=="table") then
|
||||
result = result[1];
|
||||
end
|
||||
local items = "";
|
||||
for _, input in pairs(data.input) do
|
||||
if (items=="") then
|
||||
items = items..input;
|
||||
else
|
||||
items = items..", "..input;
|
||||
end
|
||||
end
|
||||
if craftguide.register_craft then
|
||||
local items = table.concat(data.input, ", ");
|
||||
if have_cg and craftguide.register_craft then
|
||||
craftguide.register_craft({
|
||||
type = typename,
|
||||
result = result,
|
||||
|
|
Loading…
Reference in New Issue
Block a user