Tweak item name display offset, fix bugs

This commit is contained in:
Wuzzy 2017-03-08 20:16:41 +01:00
parent 9e58e928fd
commit 34a531062b
2 changed files with 7 additions and 9 deletions

@ -0,0 +1 @@
hudbars?

@ -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