skip recipes with unknown items

This commit is contained in:
Alexander Weber 2017-02-17 17:33:05 +01:00
parent cb1533bfdd
commit 87d58b9cb5
2 changed files with 22 additions and 7 deletions

View File

@ -153,7 +153,11 @@ function cache.fill_recipe_cache()
end end
end end
else else
table.insert(itemlist,recipe_item) if minetest.registered_items[recipe_item] == nil then
minetest.log("verbose", "[smartfs_inventory] unknown item in recipe: "..itemname)
else
table.insert(itemlist,recipe_item)
end
end end
cache.crecipes[recipe].recipe_items[recipe_item] = {} cache.crecipes[recipe].recipe_items[recipe_item] = {}
for _, itemname in ipairs(itemlist) do for _, itemname in ipairs(itemlist) do
@ -224,17 +228,22 @@ function cache.get_recipes_craftable_atnext(player, item)
end) end)
end end
if def then if def then
local recipe_ok = false
for recipe_item, itemtab in pairs(cache.crecipes[recipe].recipe_items) do for recipe_item, itemtab in pairs(cache.crecipes[recipe].recipe_items) do
recipe_ok = false
for _, itemname in ipairs(itemtab) do for _, itemname in ipairs(itemtab) do
if filter.is_revealed_item(itemname, player) then if filter.is_revealed_item(itemname, player) == true then
recipe_with_one_item_in_inventory[recipe] = true recipe_ok = true
break break
end end
end end
if recipe_with_one_item_in_inventory[recipe] == true then if recipe_ok == false then
break break
end end
end end
if recipe_ok then
recipe_with_one_item_in_inventory[recipe] = true
end
end end
end end
end end

View File

@ -52,9 +52,12 @@ filter.register_filter({
end end
}) })
---TODO: irgend wo einbauen!
function filter.is_revealed_item(itemname, playername) function filter.is_revealed_item(itemname, playername)
local cache = smart_inventory.cache local cache = smart_inventory.cache
if minetest.registered_items[itemname] == nil then
return false
end
if smart_inventory.doc_items_mod then if smart_inventory.doc_items_mod then
local category_id local category_id
if not cache.citems[itemname] then if not cache.citems[itemname] then
@ -72,12 +75,15 @@ function filter.is_revealed_item(itemname, playername)
end end
if category_id then if category_id then
return doc.entry_revealed(playername, category_id, itemname) return doc.entry_revealed(playername, category_id, itemname)
else
-- unknown item
return false
end end
return true --should not be happen. But take it visible if the item is not a node or tool or item
end end
end end
return true return true
end end
----------------
----------------
return filter return filter