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.
This commit is contained in:
parent
34a52a4c0f
commit
fa0142c2c0
21
api.lua
21
api.lua
@ -1,18 +1,29 @@
|
|||||||
|
|
||||||
-- Create detached creative inventory after loading all mods
|
-- Create detached creative inventory after loading all mods
|
||||||
minetest.after(0.01, function()
|
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 = {}
|
unified_inventory.items_list = {}
|
||||||
for name, def in pairs(minetest.registered_items) do
|
for name, def in pairs(minetest.registered_items) do
|
||||||
if (not def.groups.not_in_creative_inventory or
|
if (not def.groups.not_in_creative_inventory or
|
||||||
def.groups.not_in_creative_inventory == 0) and
|
def.groups.not_in_creative_inventory == 0) and
|
||||||
def.description and def.description ~= "" then
|
def.description and def.description ~= "" then
|
||||||
table.insert(unified_inventory.items_list, name)
|
table.insert(unified_inventory.items_list, name)
|
||||||
local recipes = minetest.get_all_craft_recipes(name)
|
local all_names = rev_aliases[name] or {}
|
||||||
if recipes then
|
table.insert(all_names, name)
|
||||||
unified_inventory.crafts_table[name] = recipes
|
local all_recipes = {}
|
||||||
else
|
for _, name in ipairs(all_names) do
|
||||||
unified_inventory.crafts_table[name] = {}
|
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
|
end
|
||||||
|
unified_inventory.crafts_table[name] = all_recipes
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.sort(unified_inventory.items_list)
|
table.sort(unified_inventory.items_list)
|
||||||
|
Loading…
Reference in New Issue
Block a user