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
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
cache.crecipes[recipe].recipe_items[recipe_item] = {}
for _, itemname in ipairs(itemlist) do
@ -224,17 +228,22 @@ function cache.get_recipes_craftable_atnext(player, item)
end)
end
if def then
local recipe_ok = false
for recipe_item, itemtab in pairs(cache.crecipes[recipe].recipe_items) do
recipe_ok = false
for _, itemname in ipairs(itemtab) do
if filter.is_revealed_item(itemname, player) then
recipe_with_one_item_in_inventory[recipe] = true
if filter.is_revealed_item(itemname, player) == true then
recipe_ok = true
break
end
end
if recipe_with_one_item_in_inventory[recipe] == true then
if recipe_ok == false then
break
end
end
if recipe_ok then
recipe_with_one_item_in_inventory[recipe] = true
end
end
end
end

View File

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