From 34a531062b54e3de7a8884b202d267b69206caec Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 8 Mar 2017 20:16:41 +0100 Subject: [PATCH] Tweak item name display offset, fix bugs --- mods/HUD/mcl_item_names/depends.txt | 1 + mods/HUD/mcl_item_names/init.lua | 15 ++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) create mode 100644 mods/HUD/mcl_item_names/depends.txt diff --git a/mods/HUD/mcl_item_names/depends.txt b/mods/HUD/mcl_item_names/depends.txt new file mode 100644 index 000000000..3e1d5c201 --- /dev/null +++ b/mods/HUD/mcl_item_names/depends.txt @@ -0,0 +1 @@ +hudbars? diff --git a/mods/HUD/mcl_item_names/init.lua b/mods/HUD/mcl_item_names/init.lua index 243b938b5..2a71723dd 100644 --- a/mods/HUD/mcl_item_names/init.lua +++ b/mods/HUD/mcl_item_names/init.lua @@ -4,18 +4,10 @@ local wield = {} local huds = {} local dtimes = {} local dlimit = 3 -- HUD element will be hidden after this many seconds -local air_hud_mod = minetest.get_modpath("4air") -local hud_mod = minetest.get_modpath("hud") -local hudbars_mod = minetest.get_modpath("hudbars") local function set_hud(player) local player_name = player:get_player_name() - local off = {x=0, y=-70} - if air_hud_mod or hud_mod then - off.y = off.y - 20 - elseif hudbars_mod then - off.y = off.y + 13 - end + local off = {x=0, y=-136} huds[player_name] = player:hud_add({ hud_elem_type = "text", position = {x=0.5, y=1}, @@ -48,6 +40,11 @@ minetest.register_globalstep(function(dtime) if huds[player_name] then local def = minetest.registered_items[wstack] local desc = def and def.description or "" + -- Cut off item description after first newline + local firstnewline = string.find(desc, "\n") + if firstnewline then + desc = string.sub(desc, 1, firstnewline-1) + end player:hud_change(huds[player_name], 'text', desc) end end