From 59b806c9c494b98f0f67015afa4978f75d17b309 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Wed, 11 Sep 2019 12:25:28 +0200 Subject: [PATCH] Progressive: Update items in sfinv without page change --- init.lua | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index f9ea300..3f56830 100644 --- a/init.lua +++ b/init.lua @@ -309,10 +309,10 @@ local function get_filtered_items(player, data) usages = #apply_recipe_filters(usages or {}, player) if recipes > 0 or usages > 0 then - if not data then - c = c + 1 - items[c] = item - else + c = c + 1 + items[c] = item + + if data then known = known + recipes + usages end end @@ -320,9 +320,9 @@ local function get_filtered_items(player, data) if data then data.known_recipes = known - else - return items end + + return items end local function get_usages(item) @@ -1303,12 +1303,19 @@ if progressive_mode then data.inv_items = table_merge(diff, data.inv_items) local oldknown = data.known_recipes or 0 - get_filtered_items(player, data) + local items = get_filtered_items(player, data) + data.discovered = data.known_recipes - oldknown if data.show_hud == nil and data.discovered > 0 then data.show_hud = true end + + if sfinv_only then + data.items_raw = items + search(data) + sfinv.set_player_inventory_formspec(player) + end end end