From fa0142c2c005ba8bf1bc44a2e0c9d34fbd2f1cf4 Mon Sep 17 00:00:00 2001 From: Zefram Date: Tue, 22 Apr 2014 20:12:49 +0100 Subject: [PATCH 1/3] Look for recipes under an item's aliases get_all_craft_recipes() returns the recipes that were registered under the specified name, so asking about an item's canonical name won't see recipes registered under an alias, and vice versa. Several mods register recipes under aliases, so the craft guide was missing that handful of recipes. To work around it, invert the aliases table and ask explicitly about each alias. --- api.lua | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/api.lua b/api.lua index 03705e6..3a694b4 100644 --- a/api.lua +++ b/api.lua @@ -1,18 +1,29 @@ -- Create detached creative inventory after loading all mods minetest.after(0.01, function() + local rev_aliases = {} + for source, target in pairs(minetest.registered_aliases) do + if not rev_aliases[target] then rev_aliases[target] = {} end + table.insert(rev_aliases[target], source) + end unified_inventory.items_list = {} for name, def in pairs(minetest.registered_items) do if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) and def.description and def.description ~= "" then table.insert(unified_inventory.items_list, name) - local recipes = minetest.get_all_craft_recipes(name) - if recipes then - unified_inventory.crafts_table[name] = recipes - else - unified_inventory.crafts_table[name] = {} + local all_names = rev_aliases[name] or {} + table.insert(all_names, name) + local all_recipes = {} + for _, name in ipairs(all_names) do + local recipes = minetest.get_all_craft_recipes(name) + if recipes then + for _, recipe in ipairs(recipes) do + table.insert(all_recipes, recipe) + end + end end + unified_inventory.crafts_table[name] = all_recipes end end table.sort(unified_inventory.items_list) From 910c9fad5b5d82b9670bf1a61f9ba8328027b357 Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Tue, 22 Apr 2014 16:51:09 -0400 Subject: [PATCH 2/3] Update README --- README.md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bcb3698..6f5e2d4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,22 @@ -unified_inventory +Unified inventory ================= -Replacement for Minetest creative inventory. +Unified Inventory replaces the default survival and creative inventory. +It adds a nicer interface and a number of features, such as a crafting guide. + +License +======= + +Copyright (C) 2012-2014 Maciej Kasatkin (RealBadAngel) + +Unified inventory code is licensed under the GNU LGPLv2+. + +Licenses for textures: + +VanessaE: (WTFPL) + * ui\_group.png + +RealBadAngel: (WTFPL) + * Everything else. + -Unified Inventory replaces the survival and creative inventory; it also functions as a crafting guide. From 5e52f3c49c30ff619cbbf7b5f6ea5cde652a8bf9 Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Tue, 22 Apr 2014 16:51:48 -0400 Subject: [PATCH 3/3] Add .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5236e1e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +