3be4f221ff
Can't get HUDs to align right on high-DPI/android at all. Give up on the combination breath/wield bar, switch back to a much earlier version of the code for that. For wield names, add a new tooltip to the center of the screen, and show it transiently so that it doesn't disrupt all gameplay. As a bonus, this is also a logical place to put a "what am I touching" display, so hook this up for punching. Now you can tell what you're touching even when you can't dig it. This is like a WAILA mod, but doesn't require tracing.
51 lines
1.3 KiB
Lua
51 lines
1.3 KiB
Lua
-- LUALOCALS < ---------------------------------------------------------
|
|
local minetest
|
|
= minetest
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
local health_bar_definition =
|
|
{
|
|
hud_elem_type = "statbar",
|
|
position = {x = 0.5, y = 1},
|
|
text = "nc_player_hud_heart_bg.png",
|
|
number = 20,
|
|
direction = 0,
|
|
size = {x = 24, y = 24},
|
|
offset = { x = (-10 * 24) - 25, y = -(48 + 24 + 16)},
|
|
}
|
|
|
|
local breath_bar_definition =
|
|
{
|
|
hud_elem_type = "statbar",
|
|
position = {x = 0.5, y = 1},
|
|
text = "nc_player_hud_bubble_bg.png",
|
|
number = 20,
|
|
direction = 0,
|
|
size = {x = 24, y = 24},
|
|
offset = {x = 25, y = -(48 + 24 + 16)},
|
|
}
|
|
|
|
local reg_bubbles = {}
|
|
|
|
local function checkbubbles(player)
|
|
local name = player:get_player_name()
|
|
if player:get_breath() < 11 then
|
|
reg_bubbles[name] = reg_bubbles[name] or player:hud_add(breath_bar_definition)
|
|
elseif reg_bubbles[name] then
|
|
player:hud_remove(reg_bubbles[name])
|
|
reg_bubbles[name] = nil
|
|
end
|
|
end
|
|
|
|
minetest.register_playerevent(checkbubbles)
|
|
|
|
minetest.register_on_joinplayer(function(player)
|
|
player:hud_set_hotbar_itemcount(8)
|
|
player:hud_set_hotbar_image("nc_player_hud_bar.png")
|
|
player:hud_set_hotbar_selected_image("nc_player_hud_sel.png")
|
|
minetest.after(0, function()
|
|
player:hud_add(health_bar_definition)
|
|
checkbubbles(player)
|
|
end)
|
|
end)
|