unified_inventory support for custom recipes
This commit is contained in:
parent
b853f52bd6
commit
8daed7e05e
@ -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
|
||||
|
||||
|
@ -1 +1,2 @@
|
||||
elepower_dynamics
|
||||
unified_inventory?
|
||||
|
@ -1,3 +1,4 @@
|
||||
name = elepower_machines
|
||||
description = Elepower machinery!
|
||||
depends = elepower_dynamics
|
||||
optional_depends = unified_inventory
|
||||
|
Loading…
Reference in New Issue
Block a user