Progressive: Update items in sfinv without page change

This commit is contained in:
Jean-Patrick Guerrero 2019-09-11 12:25:28 +02:00
parent db626eaece
commit 59b806c9c4

@ -309,10 +309,10 @@ local function get_filtered_items(player, data)
usages = #apply_recipe_filters(usages or {}, player) usages = #apply_recipe_filters(usages or {}, player)
if recipes > 0 or usages > 0 then if recipes > 0 or usages > 0 then
if not data then
c = c + 1 c = c + 1
items[c] = item items[c] = item
else
if data then
known = known + recipes + usages known = known + recipes + usages
end end
end end
@ -320,9 +320,9 @@ local function get_filtered_items(player, data)
if data then if data then
data.known_recipes = known data.known_recipes = known
else
return items
end end
return items
end end
local function get_usages(item) local function get_usages(item)
@ -1303,12 +1303,19 @@ if progressive_mode then
data.inv_items = table_merge(diff, data.inv_items) data.inv_items = table_merge(diff, data.inv_items)
local oldknown = data.known_recipes or 0 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 data.discovered = data.known_recipes - oldknown
if data.show_hud == nil and data.discovered > 0 then if data.show_hud == nil and data.discovered > 0 then
data.show_hud = true data.show_hud = true
end end
if sfinv_only then
data.items_raw = items
search(data)
sfinv.set_player_inventory_formspec(player)
end
end end
end end