diff --git a/elepower_machines/craft.lua b/elepower_machines/craft.lua index c69738d..baafc06 100644 --- a/elepower_machines/craft.lua +++ b/elepower_machines/craft.lua @@ -1,3 +1,4 @@ +local have_ui = minetest.get_modpath("unified_inventory") elepm.craft = {} elepm.craft.types = {} @@ -10,6 +11,14 @@ function elepm.register_craft_type(name, def) gui_name = def.gui_name, } + if have_ui and unified_inventory.register_craft_type then + unified_inventory.register_craft_type(name, { + description = def.description or name, + width = def.inputs or 2, + height = 1, + }) + end + elepm.craft[name] = {} end @@ -54,6 +63,34 @@ function elepm.register_craft(craftdef) time = time } + if have_ui then + local spec = {} + + for item, count in pairs(recipe.recipe) do + spec[#spec+1] = ItemStack(item .. " " .. count) + end + + if type(recipe.output) == "table" then + for _,itm in pairs(recipe.output) do + local itmst = ItemStack(itm) + unified_inventory.register_craft({ + type = craftdef.type, + output = itmst, + items = spec, + width = 0, + }) + end + return + end + + unified_inventory.register_craft({ + type = craftdef.type, + output = recipe.output, + items = spec, + width = 0, + }) + end + table.insert(elepm.craft[ctype], recipe) end diff --git a/elepower_machines/depends.txt b/elepower_machines/depends.txt index ed2da64..41c5ae6 100644 --- a/elepower_machines/depends.txt +++ b/elepower_machines/depends.txt @@ -1 +1,2 @@ elepower_dynamics +unified_inventory? diff --git a/elepower_machines/mod.conf b/elepower_machines/mod.conf index 4e0c5eb..6620a8f 100644 --- a/elepower_machines/mod.conf +++ b/elepower_machines/mod.conf @@ -1,3 +1,4 @@ name = elepower_machines description = Elepower machinery! depends = elepower_dynamics +optional_depends = unified_inventory