forked from VoxeLibre/VoxeLibre
Tweak item name display offset, fix bugs
This commit is contained in:
parent
9e58e928fd
commit
34a531062b
|
@ -0,0 +1 @@
|
||||||
|
hudbars?
|
|
@ -4,18 +4,10 @@ local wield = {}
|
||||||
local huds = {}
|
local huds = {}
|
||||||
local dtimes = {}
|
local dtimes = {}
|
||||||
local dlimit = 3 -- HUD element will be hidden after this many seconds
|
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 function set_hud(player)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
local off = {x=0, y=-70}
|
local off = {x=0, y=-136}
|
||||||
if air_hud_mod or hud_mod then
|
|
||||||
off.y = off.y - 20
|
|
||||||
elseif hudbars_mod then
|
|
||||||
off.y = off.y + 13
|
|
||||||
end
|
|
||||||
huds[player_name] = player:hud_add({
|
huds[player_name] = player:hud_add({
|
||||||
hud_elem_type = "text",
|
hud_elem_type = "text",
|
||||||
position = {x=0.5, y=1},
|
position = {x=0.5, y=1},
|
||||||
|
@ -48,6 +40,11 @@ minetest.register_globalstep(function(dtime)
|
||||||
if huds[player_name] then
|
if huds[player_name] then
|
||||||
local def = minetest.registered_items[wstack]
|
local def = minetest.registered_items[wstack]
|
||||||
local desc = def and def.description or ""
|
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)
|
player:hud_change(huds[player_name], 'text', desc)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue