Fixed offset in show_wielded_item
This commit is contained in:
parent
405c1c1433
commit
d56ce6c456
@ -1,5 +1,5 @@
|
||||
# Show Wielded Item [`show_wielded_item`]
|
||||
This Minetest mod displays the name of the wielded item above the hotbar and
|
||||
This mod displays the name of the wielded item above the hotbar and
|
||||
statbars.
|
||||
|
||||
This mod is compatible with the HUD Bars [`hudbars`] mod.
|
||||
|
@ -9,31 +9,18 @@ local dlimit = 3 -- HUD element will be hidden after this many seconds
|
||||
-- Legacy support: Name of the HUD type field for 'hud_add'.
|
||||
local hud_type_field_name
|
||||
if minetest.features.hud_def_type_field then
|
||||
-- Minetest 5.9.0 and later
|
||||
-- engine version 5.9.0 and later
|
||||
hud_type_field_name = "type"
|
||||
else
|
||||
-- All Minetest versions before 5.9.0
|
||||
-- All engine versions before 5.9.0
|
||||
hud_type_field_name = "hud_elem_type"
|
||||
end
|
||||
|
||||
local function set_hud(player)
|
||||
if not player:is_player() then return end
|
||||
local player_name = player:get_player_name()
|
||||
-- Fixed offset in config file
|
||||
local fixed = nil
|
||||
local off
|
||||
if fixed and fixed ~= -1 then
|
||||
-- Manual offset
|
||||
off = {x=0, y=-fixed}
|
||||
else
|
||||
-- Default offset
|
||||
off = {x=0, y=-101}
|
||||
|
||||
-- Dirty trick to avoid collision with Minetest's status text (e.g. “Volume changed to 0%”)
|
||||
if off.y >= -167 and off.y <= -156 then
|
||||
off.y = -181
|
||||
end
|
||||
end
|
||||
-- Offset
|
||||
local off = {x=0, y=-101}
|
||||
|
||||
huds[player_name] = player:hud_add({
|
||||
[hud_type_field_name] = "text",
|
||||
|
Loading…
x
Reference in New Issue
Block a user