mirror of
https://github.com/minetest-mods/unified_inventory.git
synced 2025-06-29 23:10:45 +02:00
Show item usages in craft guide
When the craft guide is showing a craft, the output slot is now a button, which causes the craft guide to show ways in which that output can be used. This mirrors the way input slots are buttons that show recipes for the selected ingredient. Usages of an item can be iterated through in the same way as recipes for the item. This incidentally offers some ability to retrace one's steps through a crafting chain, without storing actual history.
This commit is contained in:
22
group.lua
22
group.lua
@ -1,3 +1,25 @@
|
||||
function unified_inventory.canonical_item_spec_matcher(spec)
|
||||
local specname = ItemStack(spec):get_name()
|
||||
if specname:sub(1, 6) == "group:" then
|
||||
local group_names = specname:sub(7):split(",")
|
||||
return function (itemname)
|
||||
local itemdef = minetest.registered_items[itemname]
|
||||
for _, group_name in ipairs(group_names) do
|
||||
if (itemdef.groups[group_name] or 0) == 0 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
else
|
||||
return function (itemname) return itemname == specname end
|
||||
end
|
||||
end
|
||||
|
||||
function unified_inventory.item_matches_spec(item, spec)
|
||||
local itemname = ItemStack(item):get_name()
|
||||
return unified_inventory.canonical_item_spec_matcher(spec)(itemname)
|
||||
end
|
||||
|
||||
unified_inventory.registered_group_items = {
|
||||
mesecon_conductor_craftable = "mesecons:wire_00000000_off",
|
||||
|
Reference in New Issue
Block a user