diff --git a/init.lua b/init.lua index bf1e58a..a1ecb33 100644 --- a/init.lua +++ b/init.lua @@ -493,32 +493,22 @@ local function get_inv_items(player) return inv_items end -local function progressive_show_recipe(recipe, inv_items) - local inv_items_size = #inv_items - for _, item in pairs(recipe.items) do - local item_in_inv - if item:sub(1,6) == "group:" then - local groups = extract_groups(item) - for i = 1, inv_items_size do - local item_groups = reg_items[inv_items[i]].groups - if item_has_groups(item_groups, groups) then - item_in_inv = true - end - end - else - for i = 1, inv_items_size do - if inv_items[i] == item then - item_in_inv = true - end +local function item_in_inv(item, inv_items) + if item:sub(1,6) == "group:" then + local groups = extract_groups(item) + for i = 1, #inv_items do + local item_groups = reg_items[inv_items[i]].groups + if item_has_groups(item_groups, groups) then + return true end end - - if not item_in_inv then - return + else + for i = 1, #inv_items do + if inv_items[i] == item then + return true + end end end - - return true end local function progressive_default_filter(recipes, player) @@ -530,7 +520,14 @@ local function progressive_default_filter(recipes, player) local filtered = {} for i = 1, #recipes do local recipe = recipes[i] - if progressive_show_recipe(recipe, inv_items) then + local recipe_in_inv = true + for _, item in pairs(recipe.items) do + if not item_in_inv(item, inv_items) then + recipe_in_inv = false + end + end + + if recipe_in_inv then filtered[#filtered + 1] = recipe end end