From 87f502a2592bbd41e99df9009a966111156f0181 Mon Sep 17 00:00:00 2001 From: Zefram Date: Fri, 13 Jun 2014 15:04:20 +0100 Subject: Show item usages in craft guide When the craft guide is showing a craft, the output slot is now a button, which causes the craft guide to show ways in which that output can be used. This mirrors the way input slots are buttons that show recipes for the selected ingredient. Usages of an item can be iterated through in the same way as recipes for the item. This incidentally offers some ability to retrace one's steps through a crafting chain, without storing actual history. --- internal.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'internal.lua') diff --git a/internal.lua b/internal.lua index 2323e07..4d9c10b 100644 --- a/internal.lua +++ b/internal.lua @@ -71,6 +71,7 @@ function unified_inventory.get_formspec(player, page) if #unified_inventory.filtered_items_list[player_name] == 0 then formspec = formspec.."label[8.2,0;No matching items]" else + local dir = unified_inventory.active_search_direction[player_name] local list_index = unified_inventory.current_index[player_name] local page = math.floor(list_index / (80) + 1) local pagemax = math.floor( @@ -84,7 +85,7 @@ function unified_inventory.get_formspec(player, page) formspec = formspec.."item_image_button[" ..(8.2 + x * 0.7).."," ..(1 + y * 0.7)..";.81,.81;" - ..name..";item_button_" + ..name..";item_button_"..dir.."_" ..unified_inventory.mangle_for_formspec(name)..";]" list_index = list_index + 1 end @@ -108,7 +109,7 @@ function unified_inventory.set_inventory_formspec(player, page) end --apply filter to the inventory list (create filtered copy of full one) -function unified_inventory.apply_filter(player, filter) +function unified_inventory.apply_filter(player, filter, search_dir) local player_name = player:get_player_name() local lfilter = string.lower(filter) local ffilter @@ -139,6 +140,7 @@ function unified_inventory.apply_filter(player, filter) unified_inventory.filtered_items_list_size[player_name] = #unified_inventory.filtered_items_list[player_name] unified_inventory.current_index[player_name] = 1 unified_inventory.activefilter[player_name] = filter + unified_inventory.active_search_direction[player_name] = search_dir unified_inventory.set_inventory_formspec(player, unified_inventory.current_page[player_name]) end -- cgit v1.2.3