mcl_maps: send hud_flags only if actually changed

This commit is contained in:
cora 2021-09-13 14:13:46 +02:00
parent 07a59ef120
commit eee94658e7

View file

@ -43,13 +43,19 @@ end
-- Checks if player is still allowed to display the minimap
local function update_minimap(player)
local creative = minetest.is_creative_enabled(player:get_player_name())
if creative then
player:hud_set_flags({minimap=true, minimap_radar = true})
else
if has_item_in_hotbar(player, "mcl_maps:filled_map") then
player:hud_set_flags({minimap = true, minimap_radar = false})
local newstate=false
local oldstate=player:hud_get_flags().minimap
if creative or has_item_in_hotbar(player, "mcl_maps:filled_map") then
newstate=true
end
if oldstate ~= newstate then
if creative then
player:hud_set_flags({minimap = true, minimap_radar = true})
else
player:hud_set_flags({minimap = false, minimap_radar = false})
player:hud_set_flags({minimap = newstate, minimap_radar = false})
end
end
end