Fix reshowing caption on same player

If only one player is online and they are idling in
darkness, it makes the "Watching: " caption show
up too frequently.  Instead, only show the caption
when we change to a different player.
This commit is contained in:
Aaron Suen 2022-04-22 00:09:27 -04:00
parent 2f3985f1d3
commit fd41bd6a52

View File

@ -122,17 +122,19 @@ local function camcheck(player, dtime)
local data = getdata(player)
local text = ""
if data.target and data.tipttl then
data.tipttl = data.tipttl - dtime
if data.tipttl > 0 then
text = "Watching: " .. data.target
end
if data.target then
text = "Watching: " .. data.target
end
if data.tip then
if text ~= data.tip.text then
player:hud_change(data.tip.id, "text", text)
data.tip.text = text
if text ~= data.tip.text then data.tip.time = 0 end
data.tip.text = text
local show = text
if data.tip.time >= 2 then show = "" end
if data.tip.show ~= show then
player:hud_change(data.tip.id, "text", show)
data.tip.show = text
end
data.tip.time = data.tip.time + dtime
elseif text ~= "" then
data.tip = {
id = player:hud_add({
@ -143,7 +145,9 @@ local function camcheck(player, dtime)
alignment = {x = 0, y = -1},
offset = {x = 0, y = -8},
}),
text = text
text = text,
show = text,
time = 0
}
end
@ -160,6 +164,7 @@ local function camcheck(player, dtime)
local target = data.tracktime and data.target
target = target and minetest.get_player_by_name(target)
if not target then
data.target = nil
if not (data.queue and #data.queue > 0) then
local q = {}
local pname = player:get_player_name()
@ -184,7 +189,6 @@ local function camcheck(player, dtime)
if not target then return camdummy(player, data, dtime) end
data.dummycam = nil
data.tipttl = 2
end
local pos = player:get_pos()