From 290d0dd9c2194d29732220c900d637a7dcc7e7fc Mon Sep 17 00:00:00 2001 From: Aaron Suen Date: Sun, 24 Nov 2019 20:02:42 -0500 Subject: [PATCH] Show/hide HUD elements based on interact priv. If player is not allowed to interact, their model already lacked arms, so this prevents the player from seeing their hand on-screen. --- mods/nc_player_hud/setup.lua | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/mods/nc_player_hud/setup.lua b/mods/nc_player_hud/setup.lua index 05f23ee7..a67fc70b 100644 --- a/mods/nc_player_hud/setup.lua +++ b/mods/nc_player_hud/setup.lua @@ -14,13 +14,30 @@ local function breathimg(br) .. math_floor(o) end +local function sethudflags(player, pname) + pname = pname or player:get_player_name() + local privs = minetest.get_player_privs(pname) + player:hud_set_flags({ + wielditem = privs.interact or false, + healthbar = false, + breathbar = false, + minimap = false, + minimap_radar = false + }) +end + +local function grantrevoke(pname) + minetest.after(0, function() + local player = minetest.get_player_by_name(pname) + if player then return sethudflags(player, pname) end + end) +end + +minetest.register_on_priv_grant(grantrevoke) +minetest.register_on_priv_revoke(grantrevoke) + minetest.register_on_joinplayer(function(player) - player:hud_set_flags({ - healthbar = false, - breathbar = false, - minimap = false, - minimap_radar = false - }) + sethudflags(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")