Skip to content

Commit

Permalink
Revert latest playertag changes
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneWolfHT committed May 21, 2024
1 parent 85ce128 commit d0a5a4f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 31 deletions.
25 changes: 8 additions & 17 deletions mods/ctf/ctf_modebase/features.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ local LOADING_SCREEN_TARGET_TIME = 7
local loading_screen_time

local function update_playertag(player, t, nametag, team_nametag, symbol_nametag)
if not nametag.object or not team_nametag.object or not symbol_nametag.object then
return -- TODO: Fix the issue
end

if
not nametag.object.set_observers or
not team_nametag.object.set_observers or
if not nametag.object.set_observers or
not team_nametag.object.set_observers or
not symbol_nametag.object.set_observers
then
return
Expand Down Expand Up @@ -63,11 +58,9 @@ local function update_playertag(player, t, nametag, team_nametag, symbol_nametag
end

-- Occasionally crashes in singleplayer, so call it safely
pcall(function()
nametag.object:set_observers(entity_players )
team_nametag.object:set_observers(nametag_players)
symbol_nametag.object:set_observers(symbol_players )
end)
nametag.object:set_observers(entity_players )
team_nametag.object:set_observers(nametag_players)
symbol_nametag.object:set_observers(symbol_players )
end

local tags_hidden = false
Expand Down Expand Up @@ -115,11 +108,9 @@ local function set_playertags_state(state)

if nametag and team_nametag and symbol_entity and
nametag.object.set_observers and team_nametag.object.set_observers and symbol_entity.object.set_observers then
pcall(function()
team_nametag.object:set_observers({})
symbol_entity.object:set_observers({})
nametag.object:set_observers({})
end)
team_nametag.object:set_observers({})
symbol_entity.object:set_observers({})
nametag.object:set_observers({})
end
end
end
Expand Down
18 changes: 4 additions & 14 deletions mods/other/playertag/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,20 @@ local function add_entity_tag(player, old_observers)
color = {a = 0, r = 0, g = 0, b = 0}
})

local ppos = player:get_pos()

local ent = minetest.add_entity(ppos, "playertag:tag")
local ent = minetest.add_entity(player:get_pos(), "playertag:tag")
local ent2 = false
local ent3 = false

if ent.set_observers then
ent2 = minetest.add_entity(ppos, "playertag:tag")
ent2 = minetest.add_entity(player:get_pos(), "playertag:tag")
ent2:set_observers(old_observers.nametag_entity or {})
ent2:set_properties({
nametag = player:get_player_name(),
nametag_color = "#EEFFFFDD",
nametag_bgcolor = "#0000002D"
})

ent3 = minetest.add_entity(ppos, "playertag:tag")
ent3 = minetest.add_entity(player:get_pos(), "playertag:tag")
ent3:set_observers(old_observers.symbol_entity or {})
ent3:set_properties({
collisionbox = { 0, 0, 0, 0, 0, 0 },
Expand Down Expand Up @@ -154,17 +152,9 @@ minetest.register_entity("playertag:tag", {
physical = false,
makes_footstep_sound = false,
backface_culling = false,
static_save = true,
static_save = false,
pointable = false,
on_punch = function() return true end,
on_detach = function(self, parent)
self.object:remove()
end,
on_deactivate = function(self, removal)
if not removal then
self.object:remove()
end
end,
})

minetest.register_on_joinplayer(function(player)
Expand Down

0 comments on commit d0a5a4f

Please sign in to comment.