From f40ed854d08ce0588a3d3409b69ed8f30d016db7 Mon Sep 17 00:00:00 2001 From: marco_a <4279489-marco_a@users.noreply.gitlab.com> Date: Mon, 2 Sep 2024 00:55:06 +0200 Subject: [PATCH] Partially revert latest commit (fixes #334) --- src/hud/hud_main.lua | 80 +++++++++++++++++++-------------------- src/hud/hud_waypoints.lua | 42 ++++++++++---------- 2 files changed, 62 insertions(+), 60 deletions(-) diff --git a/src/hud/hud_main.lua b/src/hud/hud_main.lua index 806a241..cb3e750 100644 --- a/src/hud/hud_main.lua +++ b/src/hud/hud_main.lua @@ -1,63 +1,63 @@ local player_huds = {} -- KEY: p_name, INDEX: {HUD_BG_ID, HUD_TXT_ID} - +local hud_type = minetest.features.hud_def_type_field and "type" or "hud_elem_type" function arena_lib.HUD_add(player) local HUD_TITLE_IMG = player:hud_add({ - type = "image", - position = { x = 0.5, y = 0.25}, - offset = { x = 0, y = 50}, - text = "", - scale = { x = 4, y = 1.5 }, - number = 0xFFFFFF, - z_index = 1100 + [hud_type] = "image", + position = { x = 0.5, y = 0.25}, + offset = { x = 0, y = 50}, + text = "", + scale = { x = 4, y = 1.5 }, + number = 0xFFFFFF, + z_index = 1100 }) local HUD_TITLE_TXT = player:hud_add({ - type = "text", - position = { x = 0.5, y = 0.25}, - offset = { x = 0, y = 50}, - text = "", - size = { x = 2}, - number = 0xFFFFFF, - z_index = 1100 + [hud_type] = "text", + position = { x = 0.5, y = 0.25}, + offset = { x = 0, y = 50}, + text = "", + size = { x = 2}, + number = 0xFFFFFF, + z_index = 1100 }) local HUD_BROADCAST_IMG = player:hud_add({ - type = "image", - position = { x = 0.5, y = 0.25}, - text = "", - scale = { x = 25, y = 2}, - number = 0xFFFFFF, - z_index = 1100 + [hud_type] = "image", + position = { x = 0.5, y = 0.25}, + text = "", + scale = { x = 25, y = 2}, + number = 0xFFFFFF, + z_index = 1100 }) local HUD_BROADCAST_TXT = player:hud_add({ - type = "text", - position = { x = 0.5, y = 0.25}, - text = "", - number = 0xFFFFFF, - z_index = 1100 + [hud_type] = "text", + position = { x = 0.5, y = 0.25}, + text = "", + number = 0xFFFFFF, + z_index = 1100 }) local HUD_HOTBAR_IMG = player:hud_add({ - type = "image", - position = { x = 0.5, y = 1}, - offset = {x = 0, y = -105}, - text = "", - scale = { x = 25, y = 1.5}, - number = 0xFFFFFF, - z_index = 1100 + [hud_type] = "image", + position = { x = 0.5, y = 1}, + offset = {x = 0, y = -105}, + text = "", + scale = { x = 25, y = 1.5}, + number = 0xFFFFFF, + z_index = 1100 }) local HUD_HOTBAR_TXT = player:hud_add({ - type = "text", - position = { x = 0.5, y = 1}, - offset = {x = 0, y = -105}, - text = "", - size = { x = 1, y = 1}, - number = 0xFFFFFF, - z_index = 1100 + [hud_type] = "text", + position = { x = 0.5, y = 1}, + offset = {x = 0, y = -105}, + text = "", + size = { x = 1, y = 1}, + number = 0xFFFFFF, + z_index = 1100 }) player_huds[player:get_player_name()] = {HUD_TITLE_IMG, HUD_TITLE_TXT, HUD_BROADCAST_IMG, HUD_BROADCAST_TXT, HUD_HOTBAR_IMG, HUD_HOTBAR_TXT} diff --git a/src/hud/hud_waypoints.lua b/src/hud/hud_waypoints.lua index 822bbfb..761ac92 100644 --- a/src/hud/hud_waypoints.lua +++ b/src/hud/hud_waypoints.lua @@ -1,5 +1,7 @@ local S = minetest.get_translator("arena_lib") + local waypoints = {} -- KEY: player name; VALUE: {Waypoints IDs} +local hud_type = minetest.features.hud_def_type_field and "type" or "hud_elem_type" @@ -18,10 +20,10 @@ function arena_lib.show_waypoints(p_name, mod, arena) if not arena.teams_enabled then for ID, spwn in pairs(arena.spawn_points) do local HUD_ID = player:hud_add({ - name = "#" .. ID, - type = "waypoint", - precision = 0, - world_pos = spwn.pos + [hud_type] = "waypoint", + name = "#" .. ID, + precision = 0, + world_pos = spwn.pos }) table.insert(waypoints[p_name], HUD_ID) @@ -30,10 +32,10 @@ function arena_lib.show_waypoints(p_name, mod, arena) for i = 1, #arena.teams do for ID, spwn in pairs(arena.spawn_points[i]) do local HUD_ID = player:hud_add({ - name = "#" .. ID .. ", " .. arena.teams[i].name, - type = "waypoint", - precision = 0, - world_pos = spwn.pos + [hud_type] = "waypoint", + name = "#" .. ID .. ", " .. arena.teams[i].name, + precision = 0, + world_pos = spwn.pos }) table.insert(waypoints[p_name], HUD_ID) @@ -43,10 +45,10 @@ function arena_lib.show_waypoints(p_name, mod, arena) -- punto di ritorno local HUD_ID = player:hud_add({ - name = arena.custom_return_point and S("Return point (custom)") or S("Return point"), - type = "waypoint", - precision = 0, - world_pos = arena.custom_return_point and arena.custom_return_point.pos or arena_lib.mods[mod].settings.return_point.pos + [hud_type] = "waypoint", + name = arena.custom_return_point and S("Return point (custom)") or S("Return point"), + precision = 0, + world_pos = arena.custom_return_point and arena.custom_return_point.pos or arena_lib.mods[mod].settings.return_point.pos }) table.insert(waypoints[p_name], HUD_ID) @@ -62,17 +64,17 @@ function arena_lib.show_waypoints(p_name, mod, arena) -- personalizzazioni grafiche dell'arena (quindi prob anche peggio) if arena.pos1 then local pos1 = player:hud_add({ - name = "Pos1", - type = "waypoint", - precision = 0, - world_pos = arena.pos1 + [hud_type] = "waypoint", + name = "Pos1", + precision = 0, + world_pos = arena.pos1 }) local pos2 = player:hud_add({ - name = "Pos2", - type = "waypoint", - precision = 0, - world_pos = arena.pos2 + [hud_type] = "waypoint", + name = "Pos2", + precision = 0, + world_pos = arena.pos2 }) table.insert(waypoints[p_name], pos1)