diff --git a/.luacheckrc b/.luacheckrc index 46442b1..c417482 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -7,6 +7,8 @@ globals = { "news_markdown", + "ctf_map", + "ctf_report", "ctf_modebase", "ctf_chat", "ctf_teams", "ctf_combat_mode", "irc", "hpbar", "PlayerName", diff --git a/spectator_mode/init.lua b/spectator_mode/init.lua index 39ecefa..6f4d309 100644 --- a/spectator_mode/init.lua +++ b/spectator_mode/init.lua @@ -21,6 +21,22 @@ local function hide_player(player) player:set_properties(prop) player:set_armor_groups({ immortal = 1 }) player:set_nametag_attributes({color = {a = 0, r = 255, g = 255, b = 255}, text = ""}) + + ctf_modebase.update_playertags() +end + +local old_get_allowed_nametag_observers = ctf_modebase.get_allowed_nametag_observers +function ctf_modebase.get_allowed_nametag_observers(player) + local result = old_get_allowed_nametag_observers(player) + + for _, p in pairs(minetest.get_connected_players()) do + local pn = p:get_player_name() + if minetest.check_player_privs(pn, { spectate = true }) then + result[pn] = "1" + end + end + + return result end minetest.register_chatcommand("watch", { @@ -123,12 +139,19 @@ minetest.register_on_leaveplayer(function(player) end) local function join_player(player) - local old_join_part = irc.send_join_part - if minetest.check_player_privs(player:get_player_name(), { spectate = true }) and irc.send_join_part == true then + if minetest.check_player_privs(player:get_player_name(), { spectate = true }) then hide_player(player) - irc.send_join_part = false - minetest.after(0, function() irc.send_join_part = old_join_part end) + if ctf_map.current_map then + player:set_pos(vector.add(ctf_map.current_map.pos1, vector.divide(ctf_map.current_map.size, 2))) + end + + if irc and irc.send_join_part == true then + local old_join_part = irc.send_join_part + irc.send_join_part = false + + minetest.after(0, function() irc.send_join_part = old_join_part end) + end end end diff --git a/spectator_mode/mod.conf b/spectator_mode/mod.conf index 2e6eb13..a23412c 100644 --- a/spectator_mode/mod.conf +++ b/spectator_mode/mod.conf @@ -1,2 +1,3 @@ name = spectator_mode -depends = hpbar, ctf_modebase, ctf_teams, ctf_core, irc +depends = hpbar, ctf_modebase, ctf_teams, ctf_core, ctf_map +optional_depends = irc