Added huds for spectators

Closes #2
This commit is contained in:
debiankaios 2022-10-08 13:55:14 +02:00
parent 9427ec4d38
commit 9c884d2228
2 changed files with 14 additions and 7 deletions

View File

@ -16,24 +16,31 @@ arena_lib.on_start("tnttag", function(arena)
tnttag.newwave(arena)
end)
arena_lib.on_join("tnttag", function(p_name, arena, as_spectator)
if as_spectator then
tnttag.generate_HUD(arena, p_name)
end
end)
arena_lib.on_quit("tnttag", function(arena, p_name, is_spectator, reason)
if not is_spectator then
tnttag.remove_tnthead(p_name)
tnttag.remove_HUD(arena, p_name)
end
tnttag.remove_HUD(arena, p_name)
end)
arena_lib.on_eliminate("tnttag", function(arena, p_name)
tnttag.remove_tnthead(p_name)
tnttag.remove_HUD(arena, p_name)
end)
arena_lib.on_celebration("tnttag", function(arena, winner)
arena.current_time = 0
for p_name,stats in pairs(arena.players) do
for p_name in pairs(arena.players) do
tnttag.remove_tnthead(p_name)
end
tnttag.remove_HUD(arena, winner)
for p_name in pairs(arena.players_and_spectators) do
tnttag.remove_HUD(arena, p_name)
end
end)
arena_lib.on_time_tick("tnttag", function(arena)

View File

@ -93,21 +93,21 @@ function tnttag.remove_HUD(arena, p_name)
end
function tnttag.update_player_count_hud(arena)
for p_name in pairs(arena.players) do
for p_name in pairs(arena.players_and_spectators) do
local player = minetest.get_player_by_name(p_name)
player:hud_change(tnttag.saved_huds[p_name].player_count, "text", tostring(arena.players_amount) .. "/" .. tostring(arena.original_player_amount))
end
end
function tnttag.update_wave_timer_hud(arena)
for p_name in pairs(arena.players) do
for p_name in pairs(arena.players_and_spectators) do
local player = minetest.get_player_by_name(p_name)
player:hud_change(tnttag.saved_huds[p_name].wave_timer, "text", arena.current_time%arena.wavetime)
end
end
function tnttag.update_wave_counter_hud(arena)
for p_name in pairs(arena.players) do
for p_name in pairs(arena.players_and_spectators) do
local player = minetest.get_player_by_name(p_name)
player:hud_change(tnttag.saved_huds[p_name].wave_counter, "text", tostring(arena.current_wave).."/"..tostring(arena.waves))
end