From 5915ab20f75f4286f90f7608c64ca5e0d6790bb4 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Sun, 11 Apr 2021 02:43:51 +0200 Subject: [PATCH] Fix tooltips for output with meta --- init.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 12c60cc..d4a2cce 100644 --- a/init.lua +++ b/init.lua @@ -1291,7 +1291,7 @@ local function is_fav(favs, query_item) return fav, i end -local function get_tooltip(item, info) +local function get_tooltip(item, info, pos) local tooltip if info.groups then @@ -1364,6 +1364,10 @@ local function get_tooltip(item, info) end end + if pos then + return fmt("tooltip", pos.x, pos.y, ITEM_BTN_SIZE, ITEM_BTN_SIZE, ESC(tooltip)) + end + return fmt("tooltip[%s;%s]", item, ESC(tooltip)) end @@ -1407,6 +1411,7 @@ local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_siz local count = item:get_count() local bt_s = ITEM_BTN_SIZE * 1.2 local _name = fmt("_%s", name) + local pos if meta:get_string("color") ~= "" or meta:get_string("palette_index") ~= "" then local rcp_usg = is_recipe and "rcp" or "usg" @@ -1416,8 +1421,10 @@ local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_siz fs(fmt("list[detached:i3_output_%s;main;%f,%f;1,1;]", rcp_usg, X + 0.11, Y)) fs("button", X + 0.11, Y, ITEM_BTN_SIZE, ITEM_BTN_SIZE, _name, "") - local inv = minetest.get_inventory({type = "detached", name = fmt("i3_output_%s", rcp_usg)}) + local inv = minetest.get_inventory {type = "detached", name = fmt("i3_output_%s", rcp_usg)} inv:set_stack("main", 1, item) + + pos = {x = X + 0.11, y = Y} else fs("image", X, Y - 0.11, bt_s, bt_s, PNG.slot) @@ -1448,7 +1455,7 @@ local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_siz } if next(infos) then - fs(get_tooltip(_name, infos)) + fs(get_tooltip(_name, infos, pos)) end end end