diff options
author | Wuzzy <almikes@aol.com> | 2016-08-07 01:39:19 +0200 |
---|---|---|
committer | Wuzzy <almikes@aol.com> | 2016-08-14 23:36:12 +0200 |
commit | 15f5b8e8042c635d801320a606c214643d178062 (patch) | |
tree | 6d2f985b7b3de3b8162ffd8427233c6246a45419 /register.lua | |
parent | c9d794284074dd1b3dc38a91f3dc103e5b604a4d (diff) |
Craftguide: Use better tooltips for group buttons
Diffstat (limited to 'register.lua')
-rw-r--r-- | register.lua | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/register.lua b/register.lua index 55bbdb0..ff38168 100644 --- a/register.lua +++ b/register.lua @@ -188,11 +188,24 @@ local function stack_image_button(x, y, w, h, buttonname_prefix, item) selectitem = group_item.sole and displayitem or name end local label = show_is_group and "G" or "" - return string.format("item_image_button[%f,%f;%f,%f;%s;%s;%s]", + local buttonname = minetest.formspec_escape(buttonname_prefix..unified_inventory.mangle_for_formspec(selectitem)) + local button = string.format("item_image_button[%f,%f;%f,%f;%s;%s;%s]", x, y, w, h, - minetest.formspec_escape(displayitem), - minetest.formspec_escape(buttonname_prefix..unified_inventory.mangle_for_formspec(selectitem)), - label) + minetest.formspec_escape(displayitem), buttonname, label) + if show_is_group then + local groupstring, andcount = unified_inventory.extract_groupnames(name) + local grouptip + if andcount == 1 then + grouptip = string.format(S("Any item belonging to the %s group"), groupstring) + elseif andcount > 1 then + grouptip = string.format(S("Any item belonging to the groups %s"), groupstring) + end + grouptip = minetest.formspec_escape(grouptip) + if andcount >= 1 then + button = button .. string.format("tooltip[%s;%s]", buttonname, grouptip) + end + end + return button end local recipe_text = { |