diff --git a/mods/HUD/mcl_item_names/depends.txt b/mods/HUD/mcl_item_names/depends.txt new file mode 100644 index 0000000000..3e1d5c2018 --- /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 243b938b57..2a71723ddf 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