arena_manager clean up

This commit is contained in:
Zughy 2020-11-14 12:46:22 +01:00
parent bfa8237bca
commit abf562d42e
2 changed files with 22 additions and 21 deletions

View File

@ -2,25 +2,29 @@ local saved_huds = {} -- p_name = {indexes}
function block_league.HUD_show_inputs(p_name)
function block_league.HUD_show_inputs(arena)
local HUD = {
hud_elem_type = "image",
position = {x = 0.5, y = 0.5},
text = "bl_hud_keyboard.png",
scale = { x = 4, y = 4},
number = "0xFFFFFF"
}
for pl_name, _ in pairs(arena.players) do
local player = minetest.get_player_by_name(p_name)
local HUD_ID = player:hud_add(HUD)
local HUD = {
hud_elem_type = "image",
position = {x = 0.5, y = 0.5},
text = "bl_hud_keyboard.png",
scale = { x = 4, y = 4},
number = "0xFFFFFF"
}
local player = minetest.get_player_by_name(pl_name)
local HUD_ID = player:hud_add(HUD)
saved_huds[p_name] = HUD_ID
saved_huds[pl_name] = HUD_ID
end
end
function block_league.HUD_remove_inputs(p_name)
minetest.get_player_by_name(p_name):hud_remove(saved_huds[p_name])
saved_huds[p_name] = nil
function block_league.HUD_remove_inputs(arena)
for pl_name, _ in pairs(arena.players) do
minetest.get_player_by_name(pl_name):hud_remove(saved_huds[pl_name])
saved_huds[pl_name] = nil
end
end

View File

@ -13,8 +13,6 @@ arena_lib.on_load("block_league", function(arena)
reset_meta(pl_name)
equip_weapons(arena, pl_name)
create_and_show_HUD(arena, pl_name)
block_league.HUD_show_inputs(pl_name)
arena_lib.HUD_send_msg("broadcast", pl_name, S("The game will start soon"))
block_league.refill_weapons(arena, pl_name)
end
@ -22,17 +20,16 @@ arena_lib.on_load("block_league", function(arena)
block_league.info_panel_update(arena)
end)
block_league.HUD_show_inputs(arena)
arena_lib.HUD_send_msg_all("broadcast", arena, S("The game will start soon"))
block_league.countdown_and_start(arena, 3)
end)
arena_lib.on_start("block_league", function(arena)
for pl_name, _ in pairs(arena.players) do
block_league.HUD_remove_inputs(pl_name)
end
block_league.HUD_remove_inputs(arena)
block_league.energy_refill_loop(arena)
end)