diff --git a/callbacks.lua b/callbacks.lua index 317c3c8..5874a0f 100644 --- a/callbacks.lua +++ b/callbacks.lua @@ -157,7 +157,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) -- Check clicked item image button local clicked_item for name, value in pairs(fields) do - local new_dir, mangled_item = string.match(name, "^item_button_([a-z]+)_(.*)$") + local new_dir, mangled_item = string.match(name, "^[0-9]*_?item_button_([a-z]+)_(.*)$") if new_dir and mangled_item then clicked_item = unified_inventory.demangle_for_formspec(mangled_item) if string.sub(clicked_item, 1, 6) == "group:" then diff --git a/register.lua b/register.lua index dc43932..19c4e91 100644 --- a/register.lua +++ b/register.lua @@ -159,8 +159,10 @@ ui.register_page("craft", { local function stack_image_button(x, y, w, h, buttonname_prefix, item) local name = item:get_name() local count = item:get_count() + local wear = item:get_wear() + local description = item:get_meta():get_string("description") local show_is_group = false - local displayitem = name.." "..count + local displayitem = name.." "..count.." "..wear local selectitem = name if name:sub(1, 6) == "group:" then local group_name = name:sub(7) @@ -170,7 +172,9 @@ 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 "" - local buttonname = F(buttonname_prefix..ui.mangle_for_formspec(selectitem)) + -- Unique id to prevent tooltip being overridden + local id = string.format("%i%i_", x*10, y*10) + local buttonname = F(id..buttonname_prefix..ui.mangle_for_formspec(selectitem)) local button = string.format("item_image_button[%f,%f;%f,%f;%s;%s;%s]", x, y, w, h, F(displayitem), buttonname, label) @@ -186,6 +190,8 @@ local function stack_image_button(x, y, w, h, buttonname_prefix, item) if andcount >= 1 then button = button .. string.format("tooltip[%s;%s]", buttonname, grouptip) end + elseif description ~= "" then + button = button .. string.format("tooltip[%s;%s]", buttonname, F(description)) end return button end