summaryrefslogtreecommitdiff
path: root/internal.lua
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2014-06-13 15:04:20 +0100
committerDiego Martinez <kaeza@users.sf.net>2014-06-13 11:30:09 -0300
commit87f502a2592bbd41e99df9009a966111156f0181 (patch)
treea142488895cf47cc39aa072697f701cbde3cb34c /internal.lua
parentc33efe86316342c491267c5f5d8b8fa2cdc58747 (diff)
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.
Diffstat (limited to 'internal.lua')
-rw-r--r--internal.lua6
1 files changed, 4 insertions, 2 deletions
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